给定源程序:
#include
#include
int fun(char *source, char *target)
{FILE *fs,*ft; char ch;
/**********found**********/
if((fs=fopen(source, ___1___))==NULL)
return 0;
if((ft=fopen(target, "w"))==NULL)
return 0;
printf("\nThe data in file :\n");
ch=fgetc(fs);
/**********found**********/
while(!feof(___2___))
{putchar(ch);
/**********found**********/
fputc(ch,___3___);
ch=fgetc(fs);
}
fclose(fs); fclose(ft);
printf("\n\n");
return 1;
}
main()
{char sfname[20] ="myfile1",tfname[20]="myfile2";
FILE *myf; int i; char c;
myf=fopen(sfname,"w");
printf("\nThe original data :\n");
for(i=1; i<30; i++){c='A'+rand()%;fprintf(myf, "%c",c); printf("%c",c);}
fclose(myf);printf("\n\n");
if (fun(sfname, tfname) ) printf("Succeed!");
else printf("Fail!");
}
解题答案:
/**********第一空**********/
if((fs=fopen(source, "r"))==NULL)
/**********第二空**********/
while(!feof(fs))
/**********第三空**********/
fputc(ch,ft);
******************************************
相关专题:
编辑推荐: