首页 > 移动平台 > 详细

C++ append file via ofstream

时间:2021-05-08 16:37:04      阅读:28      评论:0      收藏:0      [点我收藏+]
#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

原文:https://www.cnblogs.com/Fred1987/p/14744380.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!