Jump to content
  • Advertisement
Sign in to follow this  
supagu

windows reporting wrong file size?

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

firstly, i open a file using std::ostream at the beggning, seek to the end, get the position and save this position. Now i write some data to the end of the file. later on, i read on the contents of the file using read(buffer, origonal_file_size) as to get the contents of the file before i appended any data, i then write this back out the the file. Now i get all the old file plus i get some crap left from what i appended? im guessing it has to do with windows using \r\n for new lines? what can i do besides having to manually read through the file line by line (text file btw). the same code works perfectly on linux

Share this post


Link to post
Share on other sites
Advertisement
std::ofstream fout("filename", std::ios::binary);

The binary-thingy will make sure that no conversions are made.

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!