函数调用语句:fgets(buf,n,fp);从fp指向的文件中读入_______个字符放到buf字符数组中,函数返回值为_______。
查看答案
设有以下结构体类型:struct st{char name[8];int num;float s[4];}student[50];并且结构数组student中的元素都已有值,若要将这些元素写到硬盘fp文件中,请将以下fwrite语句补充完整:fwrite(student,_______,1,fp);
feof(fp)函数用来判断文件是否结束,如果遇到文件结束,函数值为_______,否则为_______。
以下程序由终端输入一个文件名,然后把从终端键盘输入的字符依次存放到该文件中,用#作为结束输入的标志。请填空。#include void main(){FILE * fp;char ch,fname[10];printf("lnput the name of file\n");gets(fname);if((fp= )==NULL){ printf("Cannot open\n"); exit(0);}printf("Enter data\n");while((ch=getchar())!='#')fputc( ,fp);fclose(fp);}
下面程序用变量count统计文件中字符的个数,请填入适当内容。#include void main(){FILE *fp; long count=0;if((fp=fopen(“letter.dat”,_____))==NULL){printf(“cannot open file \n”);exit(0);}while(fgetc(fp)!=EOF)_____;frintf(“count=%ld\n”,count);fclose(fp);}