0

im having major issues saving my TicTacToe game in C++.

it is mainly in the function to save the game.. im not sure also if the code is calling that function properly. il show the code.......:

{
                char save_or_not;
                cout<<"Would you like to save the game?"<<endl;
                cin>>save_or_not;
                if(save_or_not == 'y'|| save_or_not == 'Y')
                {
                    void Save_Game();
                    break;
                }
                else
                {
                    break;
                }
                .
                .
                .
                .
                .
void Game::Save_Game(char Board[3][3])
{
    int i;
	FILE *savegame = fopen("save.bin","w");
	for (i = 0; i < 3; i++)
    {
        fprintf(savegame,"%c %c %c\n", Board[i][0], Board[i][1], Board[i][2]);
    }
	fclose(savegame);
	cout<<"game saved";
}

note: Board is the array for the board.
 I am a beginner at C++ so any help in relation to this program i assure you i can thank enough. So thanks in advance.
2
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by firstPerson
-1

>>void Save_Game();

This is not how to call a function.

Since your Save_Game takes an 2d array, you need call your function
like this :

Save_Game( gameBoard) ; //where gameBoard is the board of tic-tac-toe
0

have you any ideas on the save part?

Yes.

1) You need to save your game board
2) You need to save stats : wins, losses, draw games.

Then when you load it in, all you have to do is
fill your game board, and your stats variable.

0

Yes.

1) You need to save your game board
2) You need to save stats : wins, losses, draw games.

Then when you load it in, all you have to do is
fill your game board, and your stats variable.

anything in the way of code?

0

do you know how to open a file to save it.

i think so..

i have
FILE *savegame = fopen("save.bin","w");

is that right..
by the way thanks for the help. and your patience i suppose.. not easy helpin us "amateurs"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.