I am making a C++ Command window Text Adventure, and I want it to save what number variables are currently set at. So if the player saves when they have an enchantment level of 5, the next time they go on the program and load a .dat or a save file, their enchantment level stays at five, and they will be at the same location they were when they saved.
Simply use file stream! First determine in which order are the saved variables, and then if the user wishes to save his/her progress, save the data in that order, and the next time the application is launched, prompt the user does he/she want to load an already saved file, and if so, load the data from the file in the corresponding variables.
/*your variables that the player changes automaticaly
during the course of the game*/
cout<<"Load a saved file or start a new game?(L/N)\n";
cout<<"Enter the name of your file: \n";
ifstream fin((file+".save").c_str(), ios::binary);
//input your variables
//play the game
cout<<"You chose to exit. Do you wish to save your current progress\n\
to continue the game later?(Y/N)";
cout<<"Enter the name of the file in which you want to save your progress: \n";
ofstream fout((save+".save").c_str(), ios::binary);
//output all the variables that determine a player's progress in the file.
//end the game