#include <iostream>
#include <fstream>
using namespace std;
int main(void) {
ofstream outfile("E://test_out.txt"); //输出文件绝对路径方式访问,相对路径同输入文件
ifstream infile("path//test_in.txt"); //绝对路径,注意转义字符'//'
//相对路径:path//test_in.txt
if(!infile)
{
cerr<<"error: unable to open input file!/n";
cout<<"Press any key to continue!/n";
cin.get();
return -1;
}
if(!outfile)
{
cerr<<"error: unable to open output file!/n";
cout<<"Press any key to continue!/n";
cin.get();
return -2;
}
int num;
while(infile>>num)
outfile<<num<<'/n';
cout<<"Press any key to continue!/n";
cin.get();
return 0;
}
05-18
03-11
04-15
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交