Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving?

Status
Not open for further replies.

pauiel

Programmer
Jan 19, 2004
17
0
0
US
How would you save a program? I'm wanting to make a game, but how do I do the coding for saving the game so it could be continued later?
 
Hmm, are you working in Windows? Windows has several easy way of doing it, but in the mean time be thinking of the variables you want to save. If you are interested in MFC check out the CFile class at MSDN. If not, there has to be an API to create files but I don't know what it is right off hand.

Don't forget that its not all about saving, it's also about loading. :)

-Bones
 
If you are doing a console app, you could also just save out the data using an fstream. Save it out using a format that you design, and then you can read it back in assuming it is in the same format. It is pretty easy since fstreams have basically the same usage as cin and cout.

I'd suggest making a class if you don't already have one that holds the data. Then just write save and load functions that use an ofstream and an ifstream respectively. If you ever change your format, or add new data, you don't have to change your main code, only the save and load functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top