• 2021-04-14
    以下程序中用户由键盘输入一个文件名,然后输入一串字符(用#结束输入)存放到此文件文件中形成文本文件并将字符的个数写到文件尾部,请填空。#include"stdio.h"#include"stdlib.h"voidmain(){FILE*fp;charch,fname[32];intcount=0;printf("Inputthefilename:");scanf("%s",fname);if((fp=fopen())==NULL){printf("Can'topenfile:%s
    ",fname);exit(0);}getchar();printf("Enterdata:");while((ch=getchar())!='#'){fputc(ch,fp);count++;}fprintf(,"
    %d
    ",count);fclose(fp);}
  • 举一反三