Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


File output

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

I''m trying to output to the middle of a file that already has data in it. However, when I do it, it erases everything in the file past where I output to. Example: File before: DATA1 DATA2 DATA3 Then, say I want to put the character "#" at the beginning of Data2. But when I do it, it ends up like this: File after: DATA1 # I want it to look like this: DATA1 #ATA2 DATA3 Here is the code I''m using:
ofstream outfile
outfile.seekp(6, ios::beg);
outfile << ''#'';

Share this post

Link to post
Share on other sites
dats b/c file output doesn't support inserts. you are correct that it will overwrite. to get around that read the entire file into memory, insert your insert in memory, then write the entire file back out. or just read offset -> end and then append starting at offset when you write back


[edited by - Palidine on December 3, 2002 2:45:39 PM]

Share this post

Link to post
Share on other sites

where buffer is a char* and length is an int for number of characters to write; 1 in the above case.

[edited by - Hollower on December 3, 2002 11:10:48 PM]

Share this post

Link to post
Share on other sites

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