C++ append file via ofstream

#include <iostream>
#include <ostream>
#include <istream>
#include <fstream>
#include <conio.h>
using namespace std;

void ostreamDemo6()
{
    ofstream writeFile;
    writeFile.open("WriteFile6.txt", std::ios_base::app);
    if (writeFile.is_open())
    {
        char str[10000];
        char ch;
        while (1)
        {
            cin.getline(str, 10000);
            ch = _getch();
            if (ch != 27)
            {
                writeFile << str << endl;
            }
            else
            {
                cout << "Over" << endl;
                break;
            }
        }
    }
    writeFile.close();
    cout << "Finished" << endl;
}

 

C++ append file via ofstream

上一篇:log4net小记:FileAppender不用datePattern


下一篇:axios发送post请求返回网络状态码500