I'm using Qt to read a file
std::vector<QString> text;
QFile f(file);
if (f.open(QFile::ReadWrite | QFile::Text) == false)
throw my_exception();
QTextStream in(&f);
QString line;
while(!in.atEnd()) {
line = in.readLine();
text.push_back(line);
}
f.close();
the problem with this approach is: I can't read extra newlines at the end of the file.
Suppose I have the following text file
Hello world\r\n
\r\n
I'm unable to get an empty string for the last \r\n
line. How can I solve this?