Hello.
I want to read the previous line with ifstream, while somewhere in the middle of the file.
How do I do this?
Thanks in advance.
Hello.
I want to read the previous line with ifstream, while somewhere in the middle of the file.
How do I do this?
Thanks in advance.
I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.
tellg Get position of the get pointer. (public member function)
seekg Set position of the get pointer (public member function )
fstream - C++ Reference
Use tellg() before you read a line, and store the answer somewhere.
Passing that value to seekg() will allow you to re-read the same line.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.