想问下是哪里出了问题,改来改去好几次了还是报错
#include <stdio.h>
#include <malloc.h>
typedef struct student{
int score;
struct student *next;
}list;
struct student create();
void print(list a);
int main(){
struct student *p;
p = create();
print(p);
}
struct student create(){
int i = 2;
struct student *head,*middle,end;
head = (struct student)malloc(sizeof(struct student));
end = head;
middle = end;
printf("请输入第1个学生的分数:");
scanf("%d",&middle->score);
while(middle->score){
end->next = middle;
end = middle;
printf("请输入第%d个学生的分数:",i);
scanf("%d",&middle->score);
i++
}
end = NULL;
return head;
}
void print(struct student a){
while(a->next!=0){
printf("%d",a->next.score);
a = a->next;
}
}