- 论坛徽章:
- 0
|
下面程序哪里写错了,请高人指出,谢谢啦:
#include "stdafx.h"
#include"string.h"
#include"stdlib.h"
#include"stdio.h"
struct stud_nod{
int num;
char name[20];
int score;
struct stud_nod *next;
};
struct stud_nod *creat()
{
struct stud_nod *head,*tail,*p;
int num,score;
char name[20];
int size=sizeof(struct stud_nod);
head=tail=NULL;
scanf("%d%s%d",&num,name,&score);
while(num!=0)
{
p=(struct stud_nod*)malloc(size);
p->num=num;
strcpy(p->name,name);
p->score=score;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d%s%d",&num,name,&score);
}
return head;
}
int main()
{
struct stud_nod *head;
head=creat();
while(head!=NULL)
{
printf("%8d %20s %6d\n",head->num,head->name,head->score);
head=head->next;
}
}
运行后出现以下错误信息:
|
|