以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件尾部。请填空。 #include <string.h> main() { FILE*fp: char ch

admin2010-02-13  15

问题 以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件尾部。请填空。
   #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

解析
转载请注明原文地址:https://kaotiyun.com/show/iJWp777K
0

最新回复(0)