可以运行,但不能进行输入。是哪里错了吗?(新手)
# include <stdio.h># include <malloc.h>
struct Students
{
int age;
char name[20];
float score;
};
int main()
{
int i;
int quantitylen;
struct Students * pArr;
printf("请输入想要登记的学生人数:\n");
printf("quantitylen = ");
scanf("%d\n", &quantitylen);
pArr = (struct Students * )malloc(quantitylen * sizeof(struct Students));
for (i = 0; i < quantitylen; ++i)
{
printf ("请输第%d个人学生信息\n", 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 < quantitylen; ++i)
{
printf ("第%d个入学生信息是:\n", i+1);
printf ("age = ");
printf ("age = %d", pArr[i].age);
printf ("name = ");
printf ("name = %s", pArr[i].name);
printf ("score = ");
printf ("score = %f", pArr[i].score);
}
return 0;
}