题目内容

设有以下结构体类型: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);}

下面程序由终端键盘输入字符,存放到文件中,用!结束输入,请填入适当的内容。#include #includevoid main(){FILE *fp;char ch,fname[10];printf("input name of file\n");gets(fname);if((fp=fopen(fname,"w"))==NULL){printf("cannotopen\n");exit(0);}printf("enter data:\n");while( !='!')fputc( );fclose(fp);}

答案查题题库