泉水 发表于 2014-9-23 16:31:23

c++编的一个程序运行时出现问题!

#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,ios::in);
        if(!in)
        {
                cerr<<"打开文件1失败!"<<endl;    //试了好几次老是显示打开文件1失败,求教哪里出了问题?
        return 0;
        }
        ofstream out(argv,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;
}
页: [1]
查看完整版本: c++编的一个程序运行时出现问题!