64,683
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream outfile("out_file");
ifstream infile("in_file");
if(!infile)
{
cerr<<"error:unable to open input file!"<<endl;
return -1;
}
if(!outfile)
{
cerr<<"error:unable to open outfile file!"<<endl;
return -1;
}
string word;
while(infile>>word)
outfile<<word<<' ';
return 0;
}
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream outfile("out_file.txt"); //自己创建两个文本文件,你那个是二进制格式
ifstream infile("in_file.txt"); //
if(!infile)
{
cerr<<"error:unable to open input file!"<<endl;
return -1;//这里返回退出函数了
}
if(!outfile)
{
cerr<<"error:unable to open outfile file!"<<endl;
return -1;
}
string word;
while(infile>>word)
outfile<<word<<' ';
system("pause");
return 0;
}
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream outfile("out_file");
ifstream infile("in_file");
if(!infile)
{
cerr<<"error:unable to open input file!"<<endl;
return -1;
}
if(!outfile)
{
cerr<<"error:unable to open outfile file!"<<endl;
return -1;
}
string word;
while(infile>>word)
outfile<<word<<' ';
system("pause");
//or
//getchar();
return 0;
}