#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
ofstream OutData;
OutData.open("mindsweeper.txt");
if(!OutData)
{
cerr << "Error: The file could not be opened!" << "\n";
}
else
{
OutData << "I don't know what to put here" <<endl;
OutData.close();
}
return (0);
}
I just have no idea what to put in the OutData that will save the results of the game. I can construct functions to quit the game and load the game...but how am I supposed to save the contents of it when the user wants to quit?
You should put some variable name. For an example:
Declare int variable named scores and assign it to zero.
And then instead of that text you've putted inside "OutData" put that variable name.
Then to save the game create a menu.
Create Save/Load options.
Then when the user select 'Load' write this:
OutData >> scores;
.....
NOTE: Ask for load function should be shown first when your game opens up. :).
Then all those scores will be put in a scores variable :D.
That same goes for bool, char and any other type...