Hi, mates!
After reading a sream, for example :
string str;
getline(cin,str);
i need to restore it to its previous state, saving the information in str, cause i want to use the stream again as if hasnt beet read by now. I thought of converting str to char* and the using putback()/unget() functions to put back the char-s one by one, but it would look ugly.
Thank you in advance!
That may be of help, but to use it in my case will nead a function/manipulator to move the seeker to next pos, but seekg() doesnt work properly or i dont use it correctly...
Zaita (1436) Nov 18, 2008 at 8:53pm
My question is, why do you wanna restore the stream? Why not cache the whole stream contents into a container so it can be reused?
Because im creating an input stream manipulater with one argument, that should try to read an object of type T (template), and if ot does but its not equal to the manipulator's argument, the manipulator should restore the initial state of the stream. (or if it is equal - to clrear the stream (whatever they mean by "clear "))
I'm not posting the hole task, cause i know people like you, Douas and else are not here to write our homeworks...but to guide us somehow.
Thank you!