C语言,fscanf()读数时出错

那段代码是
fq=fopen("input.dat","r")
fscanf(fq,"%f %f",&price[0],&price[1]);
for(i=0;i<PEO;i++)
fscanf(fq,"%d %d %d",&ten[i][0],&ten[i][1],&ten[i][2]);
fclose(fq);
运行后直接出现图片中的错误
input.dat文件中的内容是:
1.5 0.5
101 5 150
102 4 90
103 4 120
104 3 78
105 5 60
106 6 105

第1个回答  2009-06-26
一,把price, ten , EPO的定义补充上来;有可能数组越界
二,在fopen之后,加一个assert(fq),有可能你不知道文件要放到debug目录下;
三,点RETRY去调试,看看到哪条语句或者指令了,IDE不用来调试不太亏了吗?
=================
跟踪了半天,都跟到VC6运行时源码,终于看到这个说明:注意看第二种情况
也上网搜了一下,VC6优化过头了,如果程序没用到浮点操作,就不加载浮点库,
结果浮点输入就报运行时刻错误。你随便做个啥浮点的赋值就可以了,例如price[0]=0.0
微软很变态!!
/***
*_fptrap - trap for missing floating-point software
*
*Purpose:
* Catches these cases of incomplete f.p. software linked into a program.
*
* (1) no coprocessor present, and no emulator linked in
*
* (2) "%e", "%f", and "%g" i/o conversion formats specified, but
* not all conversion software has been linked in, because the
* program did not use any floating-point variables or expressions.本回答被提问者采纳
相似回答