#include<myhead.h>int main(int argc, const char *argv[])
{//判断是否进行了外部传参if(argc!=3){printf("input file error\n");printf("usage:./a.out srcfile destfile\n");return -1;}//定义文件指针,以只读的形式打开FILE *srcfp=NULL;srcfp=fopen(argv[1],"r");if(srcfp==NULL){perror("fopen error");return -1;}//定义文件指针,以只写的形式打开FILE *destfp=NULL;destfp=fopen(argv[2],"w");if(destfp==NULL){perror("fopen error");return -1;}int ch=0;//遍历文件的字符while((ch=fgetc(srcfp))!=EOF)//循环从文件中读取一个字符,直到读取结束为止{//将读取的数据放入目标文件中fputc(ch,destfp);}printf("拷贝成功\n");//关闭文件fclose(srcfp);fclose(destfp);return 0;
}