填空题
下面程序可用来统计文件中字符的个数。
#include<stdio.h>
main()
{FILE *fp;
long num=0;
if((fp=______)==NULL)/*第一空*/
{printf("Can not open file\n");exit(0);}
while(______)/*第二空*/
{______;}/*第三空*/
printf("num=%d\n",num);
fclose(fp);
}
【参考答案】
fopen("fname.dat","r")/*第一空。以只读模式打开文件fname.dat*/