#include "stdio.h"
#include "stdlib.h"
struct stu
{
int num;
int score;
stu * next;
} *p,*head;
void main()
{
int i;
p = head =(stu * )malloc(sizeof(stu));
if(p==NULL) exit(1);
printf("input Number and Score\n");
scanf("%d%d",&p->num,&p->score);
for(i=3;i<5;i++)
{
p->next = (stu * )malloc(sizeof(stu));
if(p->next==NULL)exit(1);
p=p->next;
printf("input number and score \n");
scanf("%d%d",&p->num,&p->score);
}
p->next=NULL;
p =head;
while(p!=NULL){
printf("%d, %d\n",p->num,p->score);
p = p->next;
}
return ;
}
什么错误?
编译错误?
运行错误?
结果错误?