Wins and Loses

I have an assignment where I had to do a devil's dice type game and use text output to emulate the screen in the IOS game. I have that all done. Now my teacher wants a file to keep track of wins and loses. I'm at complete loss how to do this(besides using fstream. I know I need to use that but as to what's contained in the code to get my numbers, I have not a clue) Any input would be great. Thanks.

Oh yeah, and I need to have the ratio displayed in my game.
Read this before asking any questions. Thank you.

http://www.cplusplus.com/forum/beginner/1/
Thank you for that. Perhaps this is more specific:
I have this but it won't stay updated from the file. It pretty much starts over each time. I need to keep a running total. For example, if you enter 'q' the first time, it should store a 1 and a 0 in the file. Let's say you quit the program then run it again. If you enter 'q', I need it then to be a 2 and a 0. Same goes for the other way around.

ofstream file;
ifstream fin;
file.open("gamestat.txt");



cin>>c;
if(c=='q'){
fin>>player;

file<<++player<<endl;
file<<satan;
}
if(c=='v'){
fin>>satan;

file<<player<<endl;
file<<++satan;
}


cout<<"You have won "<<player<<" and lost "<<satan<<endl;
file.close();
Use code tags.

You didn't output anything to the new file. If you want this to work, you need to read everything, then close the file. Open the file for writing, then write to the file. Close the file. You can't read and write from the same file at the same time, and you didn't even open the file for writing.
Topic archived. No new replies allowed.