填空题
下列程序从名为filea.dat的文本文件中逐个读入字符并显示在屏幕上。请填空。
#include <stdio.h>
main()
FILE *fp; char ch;
fp = fopen( );
ch = fgetc(fp);
while(!feof(fp)) putchar(ch); ch=fgetc(fp);
putchar("\\n"); fclose(fp);
【参考答案】
"filea.dat","r\
热门
试题
填空题
以下程序中函数fun的功能是:统计person所指结构体数组中所有性别(sex)为M的记录的个数,存入变量n中,并做为函数值返回。请填空:#include#define N 3typedef struct int num; char nam[10]; char sex;SS;int fun(SS person[]) int i, n=0;for(i=0; i<N; i++) if(______==’M’ ) n++;return n;main() SS W[N]=1, AA ,’F’,2, BB ,’M’,3, CC ,’M’; int n;n=fun(W); printf( n=%d n ,n);