刚才我写了一个,最少地调用函数,你可以参考一下:
/*filename: mycopy.c a example for copy a file to another file*/
#include
int main(int argc,char* argv)
{
FILE *fpo,*fpi;
int tmp;
char *fname;
if(argc==1)
{
printf("Syntax is mycopy sourcefile targetfile\n"

;
exit (1);
}
fpi=fopen(argv,"rb"

;
if(!fpi)
{
printf("cannot open the sourcefile!\n"

;
exit (2);
}
if(argc==2)
{
printf("Please input target file name:"

;
while(scanf("%s",&fname));
fpo=fopen(fname,"wb"

;
}
else fpo=fopen(argv,"wb"

;
if(!fpo)
{
printf("cannot creat the targetfile!\n"

;
exit (3);
}
while((tmp=fgetc(fpi))!=EOF)
fputc(tmp,fpo);
fclose(fpi);
fclose(fpo);
return 0;
}