How do I reset the file pointer to the beginning of a file?
I tried a google search, and its something like ios::beg but I couldn't get it to work.Code:ifstream fin; // blahblah fin.seekg(what goes here?);
Thanks for the help
How do I reset the file pointer to the beginning of a file?
I tried a google search, and its something like ios::beg but I couldn't get it to work.Code:ifstream fin; // blahblah fin.seekg(what goes here?);
Thanks for the help
-Webmaster-
http://www.koaworld.com
Pr0gr4m|\/|1Ng n00b
According to Google and "C++ ios rewind", it's this, according to the first hit:
The second hit says to use this:Code:fin.seekg( ios::beg );
Code:fin.seekg( 0, ios::beg );
Quzah.
Hope is the first step on the road to disappointment.
If you have already read through the entire file in between the point in your code where you open the file and then wish to "reset the file pointer" you may be running into an issue where you need to clear any flags that may have been set (eof). Call the clear member function on the stream prior to calling the seekg member function. If you don't do this, any operations on that stream will simply not work.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
don't forget ios is part of the standard library, so it would actually be:Code:fin.clear(); fin.seekg(0,std::ios::beg);
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
Edit: Got it to work, reason was totally different than I had expected :P
Last edited by Philandrew; 02-07-2005 at 06:53 PM.
-Webmaster-
http://www.koaworld.com
Pr0gr4m|\/|1Ng n00b