Jump to content
  • Advertisement
Sign in to follow this  
beebs1

Strange ifstream behaviour?

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

Hiya, I've noticed that once you read past the end of a file using std::ifstream and the 'eof' bit is set, it's not cleared when you call seekg() to seek to another position, unlike the old C functions... is this correct? Is there a way to change this behaviour? What do you think about using C file routines in a C++ program? I'm guessing there's a small performance increase (probably negligible). I'm writing some low-level file reader classes, which just need to read a set number of bytes into a buffer - is there any need to use an ifstream? Just hoping someone could comment. Many thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement
AFAIK, there's no way to change that behavior. The advantage of using a ifstream over the C style FILE * functions is that the ifstream will clean up after itself in the event of an exception. RAII is your friend.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!