Jump to content
  • Advertisement
Sign in to follow this  
freeworld

file i/o is it possible to replace chunks of text without rewritting the whole file

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

in C++ is it possible to replace one or more word(s) without having to rewrite the whole file? The way I would do it now is read in the whole text file to a vector of strings, rewrite what I wanted into the strings then write it all back to the text file. Is that the proper way of doing it? Speed isn't an issue, just want it to be clean and flexible.

Share this post


Link to post
Share on other sites
Advertisement
That's the proper way (details notwithstanding), yes.

The limitation isn't really a language one, but an OS one: files simply don't work the way you'd like them to. The goal is to be able to write everything in one continuous chunk on the HD, so if the replacement text is a different length from what it's replacing, everything would get messed up.

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!