#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char* argv[]) // 文件1的内容,复制到文件2中 main.exe source.txt target.txt
{
cout<<"Total argument number"<<endl;
cout<<argc<<endl;
cout<<"Content of argument"<<endl;
for(int i=0;i<argc;i++)
{
cout<<argv[i]<<endl;
}
string file_in(argv[1]);
string file_out(argv[2]);
ifstream fin(file_in.c_str());
ofstream fout(file_out.c_str());
if(fin.is_open() && fout.is_open() )
{
cout << file_in << " " << file_out << " 打开成功 ";
}
string str;
while(getline(fin,str))
{
cout << str << endl;
fout << str << endl;
}
fin.close();
fout.close();
return 0;
}
简单的main(int argc, char* argv[])
最新推荐文章于 2024-08-25 20:02:07 发布