标题:郁闷的实型数据?(能解释一下吗?)
只看楼主
cosixu
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2004-10-11
 问题点数:0 回复次数:1 
郁闷的实型数据?(能解释一下吗?)
#include "stdio.h"
#define size 100
struct student
{float num;
}stud[size];
main()
{int i;
 FILE *fp;
 for (i=0;i<size;i++)
      scanf("%f",&stud[i].num);
 if ((fp=fopen("t1_dat","wb"))==NULL)
    {printf("cannot open file\n");
     exit(0);
    }
 for (i=0;i<size;i++)
     if (fwrite(&stud[i],sizeof(struct student),1,fp)!=1)
  printf("file writer error\n");
}
程序运行后提示:scanf:float point formats not linked abormal program termination
为什么呢?怎么改才能将实行数据写入文件中呢?
谢了!
搜索更多相关主题的帖子: 实型 数据 解释 
2005-03-16 10:44
空前
Rank: 1
等 级:新手上路
帖 子:1146
专家分:0
注 册:2004-5-11
得分:0 
为什么要定义这样的结构体?就一个域?

#include "stdio.h"
#define size 100
struct student
{float num;
}stud[size];
main()
{int i;float f;
FILE *fp;
for (i=0;i<size;i++)
     { scanf("%f",&f); stud[i].num=f;}
if ((fp=fopen("t1_dat","wb"))==NULL)
    {printf("cannot open file\n");
     exit(0);
    }
for (i=0;i<size;i++)
     if (fwrite(&stud[i],sizeof(struct student),1,fp)!=1)
  printf("file writer error\n");
}

2005-03-16 16:36



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




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

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