输入输出学生信息,vc++6.0报错了,错误看不懂哩,求大神指教。
# include <stdio.h># include <malloc.h>
struct student
{
int age;
char name;
float score;
};
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);
}
return 0;
}