store a game

Hi I am writting a tic tac toe game and want to know how I can store the last 10 games played.

I will appreciate any help
Don't you think you should tackle one problem at a time?

http://www.cplusplus.com/forum/general/149288/
I did not know asking questions will be a problem. they are two different problems here i need to learn how to store a game .
answer is through doubly linked list:

make every game played store in a node and point to next game,
keep count,
when count reaches 10 or 20 ie. an increment by 10 save the last ten nodes and delete other.

how to delete:
traverse to start of count from tail and keep on deleteing

makes sense?
Yes I will try to do it.
I am fresh man in another major with little knowledge so I will see what I can find based on what I have learned.
Thanks
You don't need any kinds of linked lists at all. A tic-tac-toe game is just a 3x3 grid, you only need a 9-byte file at most.
I really liked the idea of the file. So far I have leraned how to open a file and write on it and tehn open it. in this case I am not sure how it will work. I am working on it, any advise ?

Thanks
file is better idea,
you can save in this format:

game1: XW 11 21 20 02 ....
game2: OW .....
game3: DD .....

in this format you save the whole game(move list). XW= X wins. OW = O wins, DD= draw.
11 21 ... are sequences of moves,
Why do you need to store who wins if you also store the complete move set?
if we need statistics of last 10 games, its quicker from result notation.
otherwise, program has to calculate result from move sequence.(and code have to be written for that)
the better question ist: What exactly do you want to store?
The result of the games?
The participants?
What?
I prefer the result of the game. I think it will be perfect if I can ad the new information to the same file instead of having another text file (for example total 10 files). but the problem is that i have not leraned about files and how to write in a file in a program like this.
if I can ad the new information to the same file instead of having another text file
This is not a problem. You just need to determine the format. For instance each line has information for each game.

i have not leraned about files
Use fstream:

http://www.cplusplus.com/reference/fstream/fstream/?kw=fstream

You need to open it, but then you can use it like cin/cout combined
what would be be program to update this file:

0 W
1 D
2 L
3 D
4 D
5 W
6 D
7 L
8 D
9 W


the way i know is,
first, open the file by ifstream;
save the file to string arr[10];
edit arr[10];
close the file;
open the file by ofstream object;
save arr[10] to the file.
close the file.


but, is it possible to open the file in by fstream object and edit it?
Topic archived. No new replies allowed.