使用ofstream将文本写入文件的末尾

3 c++ ofstream

如何使用ofstream将文本写入文件末尾而不删除其内容?

Kon*_*lph 7

您可以ios::app在打开文件时传递标志:

ofstream ofs("filename", ios::app);
Run Code Online (Sandbox Code Playgroud)