Jump to content
  • Advertisement


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


settings saver

This topic is 5591 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 have written a console program that reads strings from an INI file. It then takes user input to change the values of the strings. How do I change the values in the INI file? Do I have to read the entire thing to memory, then write it all back? Or is there some more efficient way to do it?

Share this post

Link to post
Share on other sites
The most efficient way to do this is just reading everything to memory, and than rewriting the entire file.
If it was a binary file it might be faster to just seek to the position of the data you need to rewrite, and overwrite only the bytes you want to change, but with a text file it''s not.
If you want to do that with a text file, where the length of each item is variable, you would need to read through the entire file anyway to find the position where your data needs to be stored, than store the data, and than you maybe need to move everything that''s behind the data you just stored because the length of the new item is longer/shorter than the old item. As you can see this is a lot more work, than simply reading everything to memory, and rewriting everything.

My Site

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!