Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Going back to the beginning of a text file

This topic is 5930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I''m writing a text parser. I want to do two seperate passes on the file. This means I have to start reading from the top of the file again. My first thought on how to do this was using seekg(I''m using an ifstream btw) so I''d go like this MapFile.seekg(0,ios::beg); It didn''t work. I then thought I could try closing the file then re-opening so it started reading from the top again. So I used this MapFile.close; MapFile.open("thing.map"); It still didn''t work. Can anybody tell me the way you''re meant to do it(or at least a way that works)?

Share this post

Link to post
Share on other sites
If you hit the end of file, the failbit was set and you need to clear it:



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!