#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream outfile("a.txt", ios::out);
if (!outfile)
{
cerr << "open a.txt error!" << endl;
exit(1);
}
char ch[100];
cin.getline(ch, 100);
while (ch[0] != '\0') {
outfile << ch << endl;
cin.getline(ch, 100);
}
outfile.close();
return 0;
}
非原创,参考大部分CSDN大佬们的代码