为什么C用SCANF循环取浮点数时会出错?谢谢

2025-05-13 06:40:57
推荐回答(1个)
回答1:

不会啊
#include
int main(int argc, char *argv[])
{
int i=0;
float f[3];
printf("input 3 float:\n");
for(i=0; i<3; i++)
scanf("%f",&f[i]);
for(i=0; i<3; i++)
printf("%f\t",f[i]);
return 0;
}
---------
input 3 float:
1
2
3
1.000000 2.000000 3.000000

---------------------------
我在vc6下面运行楼主的程序还是没问题的
11.2
11.200000 3.12
3.120000 4.1231
4.123100 Press any key to continue