[英]fscanf read format not work
#include <stdio.h>
int main()
{
FILE *fp = fopen("b3lyp.dat", "r");
float t[13];
double y[13];
for(int i=0; i<13; i++){
if (feof(fp))
break;
fscanf(fp,"%lf %ld",&t[i],&y[i]);
printf("%lf %ld\n", &(t[i]),&(y[i]));
}
}
我想用上面的程序读取下面的数据,
1.04981 0.043781274601002
1.06981 0.029635536304994
1.08981 0.018682198951012
1.10981 0.010554297987994
1.12981 0.004922853528996
1.14981 0.001492913057007
1.16981 0
1.18981 0.000206935596992
1.20981 0.001900993164014
1.22981 0.00489135292699
1.24981 0.009006824127994
1.26981 0.014093809840006
1.28981 0.020014492864988
而我总是得到如下的printf。 我想以长浮点或双精度读取数据,正确的方法应该是什么? 谢谢你的帮助
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.