TL;DR: I want to remember the line number when using function std::getline(), so when std::getline finishes at line 33, I would like to resume my searches at line 33 forgetting about the lines before it.
I'm reading data from a text file, the text file is acting like a instance of an database. Most of my reading relies on std::getline() function, as data is ordered I know that the the next line MAY contain certain data, although when my all statements are executed it jumps back to "while (std::getline(infile, line))" function but it starts at line 2. How would I store the "std::getline" state(line number)?
I've tried using
int buffer;
ifstream_file.read(reinterpret_cast<char *>(&buffer), sizeof(buffer));
ifstream_file.seekg(-1 * sizeof(buffer), std::ios::cur);
although that doesn't quite work there, I can't exactly say why(sorry for that!).
That's how it all begins(rest of the code are just std::getlines())
while (std::getline(ifstream_file, line)) {
Aucun commentaire:
Enregistrer un commentaire