Jump to content
  • Advertisement


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


ifstream seekg() problem.

This topic is 5824 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

Hi, I have encountered a problem when I try to use seekg but I havn''t been able to resolve it. I read commands from a file like this: my_ifstream >> command; ''command'' is a string object. Everything works fine until I come to the end of the file and I want to start reading from the beginning again. I then call seekg(ios::begin) and the position is reset to the beginning of the file. But, when I try ''my_ifstream >> command'' after the call to seekg nothing is inserted in the command string and the fail bit of the ifstream becomes set... It seems like the file stream has not been reseted (but a call to tellg() afterwards indicates that the possition is set to zero). Does anyone see what I am doing wrong? Should any other function be used to reset the file stream? Regards Anomaly E

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!