Fstream alternative to rewind?
Is there an fstream alternative to the stdio function rewind()?. I am using an fstream and need to move the file pointer back to the start of the file. the only way i know how to do this at the moment is to close the stream and then open it again. Can someone please help me out. Kind regards in advance.
How many times do i have to punch the fucking monkey?
There must be a seek method in the fstream class somewhere. Try looking that up...
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
istreams have the seekg function, ostreams have seekp.
Example:
I hope this helps.
Example:
is.seekg(0);is.seekg(0, ios::beg); // same as aboveis.seekg(10, ios::cur); // current position + 10is.seekg(-10, ios::end); // 10 bytes before eof
I hope this helps.
Do I have to do anything else besides move the file pointer to the start of a file to read it another time? I am asking this because after one function has finished reading it I call fin.seekg(0, ios::beg) in the next function but it doesn''t detect any strings in the file the second time it is read.
How many times do i have to punch the fucking monkey?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement