[填空題] 以下程序中用戶由鍵盤輸入一個文件名,然后輸入一串字符(用#結束輸入)存放到此文件中,形成文本文件,并將字符的個數(shù)寫到文件的尾部。請?zhí)羁铡? #inc
2021-07-20
[填空題] 以下程序中用戶由鍵盤輸入一個文件名,然后輸入一串字符(用#結束輸入)存放到此文件中,形成文本文件,并將字符的個數(shù)寫到文件的尾部。請?zhí)羁铡?/p>
#include<stdio.h>
main()
FILE *fp;
char ch,fname[32]; int count=0;
printf("Input the filename:");
scanf("%s",fname);
if((fp=fopen( (14) ,"w+"))==NULL)
print("Can’t open file:%s",fname); exit(0);
printf("Enter data:");
while((ch=getchar())!="#")fputc(ch,fp); count++;
fprintf( (15) ,"%d",count);
fclose(fp);
正確答案:
fname
詞條內容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學等領域),建議您咨詢相關領域專業(yè)人士。