编译语法没错误 输出不正确 哪位大神指点一下 谢谢
源程序:#include<stdio.h>
#include<stdlib.h>
int main(void)
{
struct st
{
int age ;
char name[20] ;
float score ;
};
int b ;
scanf("%d",&b);
struct st *a[50];
int i = 0 ;
for(i ; i<b ;i++)
{
a[i] = (struct st *) malloc(sizeof(struct st));
printf("please input age : ");
scanf("%d",a[i]->age);
printf("please input name : ");
scanf("%s",a[i]->name);
printf("please input score : ");
scanf("%.1f",a[i]->score);
printf("\n");
}
for(i = 0 ;i<b ;i++)
{
printf("%d %s %f\n",a[i]->age, a[i]->name, a[i]->score);
}
return 0 ;
}
输出如下:
3
please input age : 22
please input name : dgrg
please input score : 99
please input age : please input name : bddfb
please input score : 99
please input age : please input name : gbdfb
please input score : 66
11492368 dgrg 18305179148001886000000000.000000
11473936 bddfb 0.000000
11473936 gbdfb 0.000000
--------------------------------
Process exited after 19.25 seconds with return value 0
请按任意键继续. . .