ofstream writing deletes every thing!

I have a High_Score.txt file and I want to (after the user finishes my game) to save it to the .txt file, however everything else in the text file will get deleted! How do I stop that?

Thank you in advance!
The way I did it is just re-save all the scores.. you're gonna have to move them down the list anyway when someone gets a score greater than the lowest one.
So, for example if you have 5 entries in your file, use this:
1
2
3
4
5
6
7
8
   ofstream Output_High_Scores; 
   Output_High_Scores.open ("High_Score.txt"); 
   for (int i = 0; i< 5; i++) 
   { 
      Output_High_Scores << High_Score[i] << endl; 
      Output_High_Scores << High_Score_Name[i] << endl; 
   } 
   Output_High_Scores.close ( ); 

Don't know if you're including names, but I'm assuming yes
Last edited on
Topic archived. No new replies allowed.