Jump to content
  • Advertisement
Sign in to follow this  
Mantear

C++ std::fstream, ios::binary question

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

Greetings! I have a question about the behavior of the ios::binary flag when opening file streams. I captured a bunch of data and wrote it to a file without the ios::binary flag set using the .write() function. When I read the data back, I now correctly have the ios::binary flag set when opening the file and reading the data using .read(). My question is, what happened to the data when I wrote it not using the ios::binary flag? I have a little bit of extra data in my file and I can only assume it was from not having the file set to be written as binary. I've made the corrections to the writting method but am currently unable to capture more data. I was hoping there was a way to undo what happened so I can use the data sets I have available.

Share this post


Link to post
Share on other sites
Advertisement
You might try opening the file as text, reading it all into a buffer, and then writing it out again as binary.

You probably should also read this.

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!