ofstream 追加模式

发布时间 2023-07-22 14:25:01作者: lydstory
#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;
}