高手帮忙指点下哪有问题
#include<stdio.h>#include<stdlib.h>
#include<string.h>
struct stud_node{
int num;
char name[20];
int score;
struct stud_node*next;
};
struct stud_node*Creat_Stu_Doc();
void Print_Stu_Doc(struct stud_node*head);
struct stud_node*Creat_Stu_Doc()
{
struct stud_node*head,*p;
int num,score;
char name[20];
int size = sizeof(struct stud_node);
head = NULL;
printf("input num,name and score:\n");
scanf("%d%s%d",&num,name,&score);
while(num!=0){
p=(struct stud_node*)malloc(size);
p->num=num;
strcpy(p->name,name);
p->score= score;
}
return head;
}
void Print_Stu_Doc(struct stud_node*head)
{
struct stud_node*ptr;
if(head == NULL){
printf("\nNo Records\n");
return ;
}
printf("\nthe students`records are:\n");
printf(" num name score\n");
for(ptr=head;ptr;ptr=ptr->next)
printf("%8d%20s%6d\n",ptr->num,ptr->name,ptr->score);
}
int main(void)
{
struct stud_node*head,*p;
int choice,num,score;
char name[20];
int size = sizeof(struct stud_node);
do{
printf("1:create 2:print 0:exit\n");
scanf("%d",&choice);
switch(choice){
case 1:
head=Creat_Stu_Doc();
break;
case 2:
Print_Stu_Doc(head);
break;
case 0:
break;
}
}while(choice != 0);
return 0;
}
运行貌似有问题 帮忙看下