ofstream 追加模式

#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;
}

  

posted on 2023-07-22 14:20  lydstory  阅读(63)  评论(0)    收藏  举报

导航