scanf()格式问题请教
程序代码:#include <stdio.h>
struct student
{
long stid;
char stname[20];
float score[3];
}stu[5];
void main ()
{
for(int i=0;i<5;i++)
scanf("%ld%s%f%f%f",&stu[i].stid,stu[i].stname,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
这个程序编译没错,但是输入值的时候会崩溃,我输入的格式是这样的:1001 zhang 10.2 11.2 12.2
我改成"%ld,%s,%f,%f,%f",输入的时候也带上逗号正常输入没问题,把float score[3]改成int型,下面scanf也改成%d也没问题,为什么会这样,希望牛人给解释下原理






