codecamp

another c++ program

#include"iostream"
#include"fstream"
using namespace std;
int main()
{
 ifstream fin1,fin2;
 ofstream fout;
 char next;
 char if_name1[15],if_name2[15],of_name[15];
 cout<<"Please enter the name of the first infile"<<endl;
 cin>>if_name1;
 fin1.open(if_name1);
 if(fin1.fail())
 {
  cout<<"Can not open the infile "<<if_name1<<endl;
  exit(1);
 }
 
 cout<<"please enter the name of the outfile"<<endl;
 cin>>of_name;
 fout.open(of_name);
 if(fout.fail())
 {
  cout<<"Can not open the outfile "<<of_name<<endl;
  exit(1);
 }
 
 while(!fin1.eof())
 {
  fin1.get(next);
  fout<<next;
 }
 fin1.close();
 fout.close();
 
 cout<<"please enter the name of the second infile"<<endl;
 cin>>if_name2;
 fin2.open(if_name2);
 if(fin2.fail())
 {
  cout<<"Can not open the infile "<<if_name2<<endl;
  exit(1);
 }
 fout.open(of_name,ios::app);
 
 while(!fin2.eof())
 {
  fin2.get(next);
  fout<<next;
 }
 fin2.close();
 fout.close();
 
 cout<<"Succeed"<<endl;
 return 0;
}
我的第一个关于类的c++程序
mofang
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }