#include <stdio.h> #include <stdlib.h> //文件的内容复制 int main(int a,char *argv[]){ if(a!=3){ printf("useage:%s source!\n", argv[0]); exit(1); } FILE *fp1, *fp2; fp1 = fopen(argv[1],"r"); if(fp1==NULL){ printf("source file open error"); exit(1); } fp2 = fopen(argv[2],"w"); if(fp2==NULL){ printf("target file open error"); exit(1); } int ch; while((ch=fgetc(fp1)) != EOF){ fputc(ch, fp2); } //关闭流 if(fclose(fp1)!=0){ printf("source file close error"); }else if(fclose(fp2)!=0){ printf("target file close error"); } return 0; }
原文地址:https://www.cnblogs.com/wanglijun/p/8613009.html
时间: 2024-10-21 16:39:22