大哥大姐们,帮帮忙,一个链表问题,输出错误!!!
#include<stdio.h>#include<stdlib.h>
#define NULL 0
struct student{
int data;
struct student *next;
};
int main()
{
struct student *pnew,*head;
int i,num;
pnew=(struct student *)malloc(sizeof(struct student));//开辟首结点
pnew=head;
for(i=0;i<=4;i++)//输入五个学号
{
scanf("%d",&num);
pnew->data=num;
pnew->next=(struct student *)malloc(sizeof(struct student));//开辟下一个结点
if(i==4)pnew->next=NULL;
else pnew=pnew->next;
}
pnew=head;
while(pnew!=NULL)
{
printf("%d",pnew->data);
pnew=pnew->next;
printf("\n");
}
return 1;
}//创建一个链表!!!