标题:C文件问题!!!
取消只看楼主
nmdsyz000
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-7-29
 问题点数:0 回复次数:0 
C文件问题!!!
#include "stdio.h"
output()
{
  FILE *fp; int x,y,z; int num=0;
  clrscr();
  if((fp=fopen("g:\\cj.dat","r"))==NULL)
  { printf("打开文件失败,按任意键退出"); getch(); exit(0); }
  fscanf(fp,"%d,%d,%d,",&x,&y,&z);
  if((x+y+z)/3>=80.0) num=num+1;
  printf("%d %d %d",x,y,z);
  printf("\n平均分数高于80的人数为: %d",num);
  getch();
}
main()
{
  FILE *fp;  char ch='a';   clrscr();
  fp=fopen("g:\\cj.dat","w+");
  if(fp==NULL) { printf("创建文件失败,按任意键继续。"); getch(); exit(0); }
  while(ch!='Q')
  {
    ch=getchar();
    fputc(ch,fp);
  }
  fclose(fp);
  output();
  getch();
}
这个程序有什么问题,为什么只能读三个数字???
搜索更多相关主题的帖子: num 文件 printf getch 
2008-07-29 19:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-225825-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.569037 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved