依旧是从Sublime Text上贴过来排版乱了、、、
#include<iostream>
#include<fstream>#include<cstdio>
#include<errno.h>
using namespace std;
int main(int argc,char* argv[]){
if(argc<3){
cout<<"用法:"<<argv[0]<<"<源文件><目标文件>"<<endl;
return -1;
}
ifstream ifs (argv[1],ios::binary);
if(!ifs){
perror("open source file failed");
return -1;
}
ofstream ofs(argv[2],ios::binary);
if(!ofs){
perror("open file failed");
return -1;
}
char buf[4096];
while(ifs.read(buf,4096))
ofs.write(buf,4096);
if(ifs.eof())
ofs.write(buf,ifs.gcount());
else
perror("read source file failed");
ofs.close();
ifs.close();
return 0;
}