Hi I got a code that in pseudo dos something like

ifstream os;

If some condition is met,
I'd like to be able to jump back to the previous line,
such that the next getline will give the line just-read in, at a later time in my execution timeline.

Is this possible?


Use two buffers or even better two std::strings:

ifstream os; // variable name misleading!
string prev, curr;
while(getline(os, curr))
   prev = curr;
commented: Good advice, simple and clever :) +12

To the OP:
Don't write your code like this: while(os.eof()) , instead write it like jencas did.
Want to know why? Do a forum search on: feof or eof :)

Edit:: I thought it was safely to assume that the 'oef' in 'os.oef()' is a typo he made.
(Because AFAIK there is no such data member in the iostream class library)