# include <stdio.h>
main(int argc,char *argv[])
{
FILE *in,*out;
char ch;
/*,infile[10],outfile[10]*/
/*
printf("enter the infile name:/n");
scanf("%s",infile);
printf("enter the outfile name:/n");
scanf("%s",outfile);*/
if(argc!=3)
{
printf("you forgot to genter a file name/n");
exit(0);
}
/*打开两个文件*/
if((in=fopen(argv[1],"r"))==NULL)
{
printf("cannot open this file/n");
exit(0);
}
out=fopen(argv[2],"w");
/*文件对拷*/
while(!feof(in))
fputc(fgetc(in),out);
fclose(in);
fclose(out);
printf("you have copy successfully");
}
本文介绍了一个使用C语言实现的简单文件复制程序。该程序通过命令行参数接收输入和输出文件名,然后逐字符地从源文件读取并写入目标文件,直至源文件结束。若操作过程中出现错误,如文件无法打开等,程序将输出错误信息并终止。
7623

被折叠的 条评论
为什么被折叠?



