Sign in to follow this  

ifstream, tellg, seekg and getline problem ...

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

This topic is 3589 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this