|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <fstream>
- #include <iostream>
- using namespace std;
- int main(int argc,char *argv[])
- {
- if(argc!=3)
- {
- cout<<"输入形式:test 源文件名 目标文件名\n"<<endl;
- exit(EXIT_FAILURE);
- }
- ifstream in;
- in.open(argv[1],ios::in);
- if(!in)
- {
- cerr<<"打开文件1失败!"<<endl; //试了好几次老是显示打开文件1失败,求教哪里出了问题?
- return 0;
- }
- ofstream out(argv[2],ios::out);
- if(!out)
- {
- cerr<<"打开文件2失败!"<<endl;
- return 0;
- }
- char ch;
- while(in>>ch)
- {
- out<<in;
- }
- out<<endl;
- in.close();
- out.close();
- system("pause");
- return 0;
- }
复制代码
|
|