File deletes contents after closing program when it should stay saved.

I initially had it so that the contents stored in the names & scores files would save even after closing the program. Now, something went wrong and the files delete their contents after closing the program and I don't know why.

Here's my code. You can check out what's going on for yourself.

http://pastebin.com/mfkDzwxE

To win a game quickly, just pick a difficulty, and during the game input '+'. That will give away the answer so that you can win quickly and get a score logged into the scoreboard.

As you can see I've been trying to pinpoint the issue with some test prints.
Last edited on
To avoid that the content is deleted use std::ofstream::app:

http://www.cplusplus.com/reference/fstream/ofstream/open/
I used it but it didn't help.

I edited it a bit but now it deletes scores one by one every time I call to print it after restarting the program. So, similar problem. It doesn't completely clear the score files after turning off the program like it did before.

http://pastebin.com/JSKa6cYd
Topic archived. No new replies allowed.