简答题
C++
题号 #2657816
编写一程序,将两个文件合并成一个文件。
参考答案
暂无
答案解析
#include<iostream>
#include<fstream>
using namespace std;
int main(){
int i=1;
char c[1000];
ifstream ifile1("D:\\10_4_3.cpp");
ifstream ifile2("D:\\10_4_4.cpp");
ofstream ofile("D:\\r10_4.cpp");
while(!ifile1.eof()){
ifile1.getline(c,999);
ofile<<c<<endl;
}
while(!ifile2.eof()){
ifile2.getline(c,999);
ofile<<c<<endl;
}
ifile1.close();
ifile2.close();
ofile.close();
return 0;
}
#include<fstream>
using namespace std;
int main(){
int i=1;
char c[1000];
ifstream ifile1("D:\\10_4_3.cpp");
ifstream ifile2("D:\\10_4_4.cpp");
ofstream ofile("D:\\r10_4.cpp");
while(!ifile1.eof()){
ifile1.getline(c,999);
ofile<<c<<endl;
}
while(!ifile2.eof()){
ifile2.getline(c,999);
ofile<<c<<endl;
}
ifile1.close();
ifile2.close();
ofile.close();
return 0;
}