if (input_stream) // if the file object was successfully created { int line = 0; // line counter array.push_back(vector<char>()); // add first empty line vector
char ch;
// get characters from the stream until EOF is reached while (input_stream.get(ch)) { array[line].push_back(ch); // add character to the end of the line vector
if (ch == '\n') // if newline encountered { ++line; // increase line counter array.push_back(vector<char>()); // add next empty line vector } } }
Comments
Leave a comment