We are trying to parse a file and stuck with one problem.
Problem is to move the file pointer to the next line if we see that we do not need the current line.
Suppose, the file(file.txt) is like this:
A quick brown fox
// Blah blah
// Blah blah
jumps over the little lazy dog
In our program, we iterate over all the file line by line by doing(skeleton):
ifstream fp("file.txt");
do {
std::string str;
std::getline(fp, str);
std::cout << str << std::endl;
} while(!foef(fp));
So, above chunk of code reads lines starting with // as well and it goes to the end of that line, thereby wasting time.
Question is: Is it possible to skip the lines which starts with //. This will save us time to traverse that line to the end.
Any help is appreciated.