ofstream 追加模式

人,唯一剥夺不了的,只有知识 / 2023-07-22 / 原文

#include 
using namespace std;

int main() {
    ofstream outfile("example.txt", ios::app);
    if (outfile.is_open()) {
        outfile << "This is a new line.\n";
        outfile.close();
    }
    else cout << "Unable to open file" << endl;
    return 0;
}