Data Storing

I am looking to create a text based game application and I currently have no problems and understand what I'm doing up until I want to create a "save file." If I was to have data for stats on their character, possibly armors/weapons, and location, what would I need to do to create the save file? I want them to be able to save the game at any point (through a command such as them entering "save") and for the data to be able to be held through the closing of the application and reloaded when they would like to resume play.
http://www.cplusplus.com/doc/tutorial/files/

Note: I personally recommend not using .open() or .close() and instead use the constructor to open the file and let the file stream go out of scope to close the file.
You'd need to make functions for storing&loading the variables you use. Pass your variables to those functions by reference (so they can read&write to it). I'd recommend that you write each variable in a new line in the file, so you could easily call getline() and get that data right away.
Topic archived. No new replies allowed.