#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;

}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2021-06-08
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-01-04
相关资源
相似解决方案