题目内容

以下程序的功能是:从键盘上输入一个字符串, 把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来.请填空.#includemain(){ FILE *fp;char str[100]; int i=0;if((fp=fopen( [BlankArea1]))==NULL){ printf("can't open this file.\n");exit(0);}printf("input astring:\n"); gets (str);while (str[i]){ if(str[i]='a'&&str[i]<='z')str[i]=___;fputc(str[i],fp);i++;}fclose(fp);fp=fopen("test.txt" [BlankArea2];);fgets(str,100,fp);printf("%s\n",str);fclose(fp);)

查看答案
更多问题

以下程序段打开文件后,先利用fseek函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度,请填空。FILE *myf; long f1;myf=fopen ("test.t","rb");( [BlankArea1] );f1=ftell(myf);fclose(myf);printf("%d\n",f1);

若fp已正确定义并指向某个文件,当未遇到该文件结束标志时函数feof(fp)的值为([BlankArea1])。

以下程序由终端键盘输入一个文件名,然后把从终端键盘输入的字符依次存放到该文件中,用#作为结束输入的标志。请填空。main( ){ FILE * fp;char ch,fname [10];printf(""Input the name of file\n"");gets(fname);gets(fname);if((fp= [BlankArea1] )= =NULL){ printf(""Cannot open\n""); exit(0); } printf(""Enter data\n"");while((ch=getchar())!='#') fputc(ch ,fp);fclose(fp);}

以下程序用来统计文件中字符个数。请填空。#include main(){ FILE *fp;long num=0L;if((fp=fopen("fname.dat","r"))==NULL){ printf("Open error\n"); exit(0);}while( [BlankArea1]){ fgetc(fp); num++;}printf("num=%1d\n",num-1);fclose(fp);}

答案查题题库