#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
//5.每次从键盘读取一行文本,输出到文件”a.txt”中,当用户输入空行时结束。
int main()
{
char strword[1024];
cin.getline(strword,1024);
ofstream outfile("a.txt",ofstream::out);
while(strlen(strword)>0){
outfile << strword << endl;
cin.getline(strword,1024);
}
return 0;
}
c++ 每次从键盘读取一行文本,输出到文件”a.txt”中,当用户输入空行时结束。
最新推荐文章于 2022-04-23 17:58:59 发布