C++ – How to read a text file from the second line using fstream


How can I make my std::fstream object start reading a text file from the second line?

Best Solution

Use getline() to read the first line, then begin reading the rest of the stream.

ifstream stream("filename.txt");
string dummyLine;
getline(stream, dummyLine);
// Begin reading your stream here
while (stream)

(Changed to std::getline (thanks dalle.myopenid.com))