Append to a File with fstream Instead of Overwriting

后端 未结 1 1159
情歌与酒
情歌与酒 2020-12-15 16:48

I\'m trying to create a basic highscore system for a project I\'m working on.

The problem I\'m having is, although I write the names into my main they just overwrite

相关标签:
1条回答
  • 2020-12-15 17:22

    You need to open the file with the append mode:

    ofstream newFile("scorefile.txt", std::ios_base::app);
    

    There are various other modes too.

    0 讨论(0)
提交回复
热议问题