Is this file reading method good enough?

to read lines from a file into a vector I am doing this:

1
2
3
4
5
6
7

std::vector <string> TextLine;
std::string Str; 
ifstream InFile("path");

while(std::getline(InFile, Str))
    TexLine.push_back(Str);


Is it important to check is_open, good, etc.
Last edited on
Your code is fine. getline() returns the stream InFile and the test invokes the void* operator which checks if the stream is good. So yes, it's important, but you are already doing it correctly.
Topic archived. No new replies allowed.