65,211
社区成员
发帖
与我相关
我的任务
分享
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
void get_data()
{
char ch[256]; //getline获取行,不能用单个字符接收
ifstream infile("data.txt",ios::in);//input data
if(!infile)
{
cerr <<"open error!" <<endl;
exit(1);
}
ofstream outfile("file.txt");//output data
if(!outfile)
{
cerr <<"error" <<endl;
exit(1);
}
while(infile.getline(ch,80)) //读取长度
{
//outfile.put(ch);
cout <<ch << endl;
}
cout <<endl;
infile.close();
outfile.close();
}
int main()
{
get_data();
return 0;}