I\'ve seen at least two ways of reading lines from a file in C++ tutorials:
std::ifstream fs(\"myfile.txt\"); if (fs.is_open()) { while (fs.good()) { s
Actually I prefer another way
for (;;) { std::string line; if (!getline(myFile, line)) break; ... }
To me it reads better, and the string is scoped correctly (i.e. inside the loop where it is being used, not outside the loop)
But of the two you've written the second is correct.