#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; }
原文:https://www.cnblogs.com/Fred1987/p/14744380.html