等级考试上机题目(上课用)(4)
时间:2026-01-17
时间:2026-01-17
第2套题
1.程序填空题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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);
}
/**********found**********/
void WriteText(FILE ___1___)
{char str[81];
printf("\nEnter string with -1 to end :\n");
gets(str);
while(strcmp(str,"-1")!=0) {
/**********found**********/
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)) {
/**********found**********/
printf("%s",___3___);
fgets(str,81,fr);
4
下一篇:LED电子屏招标公告