c++拷贝文件
#include<stdio.h>
//cp src dest
int main(int argc,char *argv[])
{
FILE *desc,*src;
char buf[4096];
if(argc <3){
printf("./mycp srcfile destfile\n");
}
src=fopen(argv[1],"r");
dest=fopen(argv[2],"w");
//if(src== NULL || desc == NULL ){
if(!src|| !dest){
printf("open file err\n");
return -1;
}
while (fgets(buf,sizeof(buf),src)!=NULL)
fputs(buf,dest);
fclose(src);
fclose(dest);
return 0;
}