填空题
以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件尾部。请填空。 #include <string.h> main() { FILE*fp: char ch,fname[32] int count=0: prinft("input the filename:"): scanf("%s",fname); if((fp=fopen(______,"w+"))==NULL) { printf("can’t open file:%s\n",fname); exit(0): } printf("enter data:\n"): while((ch=getchar())!=’$’) {fputc(ch,fp): count++; } fprintf(______,"\n%d\n", count); fclose(fp): }
【参考答案】
fname, fp
点击查看答案
<上一题
目录
下一题>
热门
试题
单项选择题
有以下程序 #include <stdio.h> main() { FILE *fp1; fp1=fopen( f1.txt , w ); fprintf(fp1, abc ); fclose(fp1); } 若文本文件f1.txt中原有内容为:good,则运行以上程序后,文件n.txt中的内容为______。
A.goodabc
B.abcd
C.abc
D.abcgood
点击查看答案
单项选择题
以下与函数fseek(fp,OL,SEEK_SET)有相同作用的是______。
A.feof(f
B.ftell(f
C.fgetc(f
D.rewind(f
点击查看答案
相关试题
下列程序是处理C盘根目录下的a.txt文件,...
以下程序可将磁盘中的一个文件复制到另一个...