Jump to content
  • Advertisement
Sign in to follow this  
paic

ifstream, tellg, seekg and getline problem ...

This topic is 3869 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 a little problem. I'm reading a file using std::getline() on a std::ifstream() At some point, I want to get the current position, read a new line, and restore the position. But for an unknown reason, the position returned by tellg is negative ... so the next getline after I restored the ifstream position fails ... Any idea of what might cause this problem ? Edit : nevermind this post ... I don't what I've done, but now it works as expected ...

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by paic
At some point, I want to get the current position, read a new line, and restore the position.


Why? You know what line comes up next in the file (you read it), so why not just reuse it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!