注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
#include
void WriteText(FILE *);
void ReadText(FILE *);
main()
{ FILE *fp;
if((fp=fopen("myfile4.txt","w"))==NULL)
{ printf(" open fail!!\n"); exit(0); }
WriteText(fp);
fclose(fp);
if((fp=fopen("myfile4.txt","r"))==NULL)
{ printf(" open fail!!\n"); exit(0); }
ReadText(fp);
fclose(fp);
}
void WriteText(FILE ___1___)
{ char str[81];
printf("\nEnter string with -1 to end :\n");
gets(str);
while(strcmp(str,"-1")!=0) {
fputs(___2___,fw); fputs("\n",fw);
gets(str);
}
}
void ReadText(FILE *fr)
{ char str[81];
printf("\nRead file and output to screen :\n");
fgets(str,81,fr);
while( !feof(fr) ) {
printf("%s",___3___);
fgets(str,81,fr);
}
}