#include <stdio.h>
#include <malloc.h>
struct student
{
int age;
float score;
char name[100];
};
void Input_student_information(struct student *, int);
void student_informatiom_processing(struct student *, int);
void output_student_information(struct student *, int);
int main(void)
{
int len;
struct student * pArr;
printf("请输入学生数:");
scanf("%d", &len);
pArr = (struct student *)malloc(sizeof(struct student)*len);
Input_student_information(pArr, len);
student_informatiom_processing(pArr, len);
output_student_information(pArr, len);
return 0;
}
void
Input_student_information(struct student * pArr, int len)
{
int i;
for (i=0; i<len; i++)
{
printf("请输入第%d位学生的信息:\n", i+1);
printf("请输入学生的年龄:");
scanf("%d", &pArr[i].age);
printf("请输入学生的成绩:");
scanf("%f", &pArr[i].score);
printf("请输入学生的姓名:");
scanf("%s", pArr[i].name[100]);//48行
}
}
void student_informatiom_processing(struct student * pArr, int len)
{
int i, j;
struct student t;
for (i=0; i<len; i++)
{
for (j=0; j<len-i-1; j++)
{
if(pArr[j].score > pArr[j+1].score)
{
t = pArr[j];
pArr[j] = pArr[j+1];
pArr[j+1] = t;
}
}
}
}
void output_student_information(struct student * pArr, int len)
{
int i;
for (i=0; i<len; i++)
{
printf("排名第%d位的学生信息为:", i+1);
printf("年龄为:%d", pArr[i].age);
printf("成绩为:%f", pArr[i].score);
printf("姓名为:%s", pArr[i].name[100]);
printf("\n");
}
}
该代码在48行哪里有个问题,去掉48行就能正常运行,否则就会出错,我实在找不出问题,求解