为什么只能输入一个人的信息,谢了
#include<stdio.h>#include<malloc.h>
struct student
{
int age;
char score;
char name[100];
};
int main(void)
{
int len;
struct student * parr;
int i;
printf("请输入学生个数:\n");
printf("len= ");
scanf("%d",&len);
parr=(struct student*)malloc(len * sizeof(struct student));
for(i=0;i<len;i++)
{
printf ("请输入第%d个学生的信息:",i+1);
printf("age=");
scanf("%d",&parr[i].age);
printf("name=");
scanf("%s",parr[i].name);
printf("score=");
scanf("%f",&parr[i].score);
}
for(i=0;i<len;i++)
{
printf ("第%d个学生的信息:\n",i+1);
printf("age=%d\n",parr[i].age);
printf("name=%s\n" ,parr[i].name );
printf("score=%f\n" ,parr[i].score);
printf("\n");
}
}