Sign in to follow this  

Saving and Loading in a Text based game.

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

How would I go about saving and loading the players stats into some sort of file, and retrieve them at a later point if they wish to continue with that character. Something like this?
#include <iostream>
#include <fstream>
#include <string>

int main()
{
std::string PlayerName = "HEro";
std::ofstream Save("Player.txt", std::ios::app);
Save << PlayerName; << std::endl;
Save.flush();
Save.close();
return 0;
}

Maybe? If that works how would I retrieve the data.

Share this post


Link to post
Share on other sites
The general term for this process is serialization, and much more informative information on it can be found here, along with google. The former should give you more than enough to look at for a while, even when you need to save fancy game states, like inventories, multiple characters, and the like.

If you have any more particular questions, let 'em rip!

Share this post


Link to post
Share on other sites

This topic is 3456 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this