trying to save a game, load a game, or quit

I'm having trouble figuring out the concepts of how I would load and save a game of mindsweeper. I thought I could use something like..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <fstream>

using namespace 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?
Last edited on
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...
Topic archived. No new replies allowed.