在链表中建立的读取函数运行时总是出错.

绿色的叶飘飞在头上的天空, 我行走在别人铺就的路上.
/*参照一下...*/
/*不带头结点的*/
typedef node* nodelink;
nodelink buildlink() /* 尾插法*/
{
datatype x;
nodelink head,s;
nodelink p2;
head=NULL;
p2=NULL;
printf("please input the link:");
scanf("%d",&x);
while(x!=0)
{s=(nodelink)malloc(sizeof(node));
s->info=x;
if (head==NULL) head=s; else p2->next=s;
p2=s;
scanf("%d",&x);
}
if(p2) p2->next=NULL;
return(head);
}
nodelink creatlink() /***头插法***/
{ nodelink head,p;
datatype x;
head=NULL;
printf("please input the link:");
scanf("%d",&x);
while(x!=0)
{ p=(nodelink)malloc(sizeof(node)) ;
p->info=x;
p->next=head;
head=p;
scanf("%d",&x);
}
return head;
}
/*带头结点的*/
typedef node* nodelink;
/* 头插法建立带头节点的单链表*/
nodelink tcreathlink()
{ datatype x;
node *head,*s;
head=(node*)malloc(sizeof(node));
printf("please input the datas:");
scanf("%d",&x);
while(x)
{ s=(node*)malloc(sizeof(node));
s->info=x;
s->next=head->next;
head->next=s;
scanf("%d",&x);
}
return head;
}
nodelink tbuildhlink() /*带头节点的尾插法*/
{
datatype x;
node *head,*s;
node *p2;
head=(node *)malloc(sizeof(node));
p2=head;
printf("please input the datas:");
scanf("%d",&x);
while(x!=0)
{s=(node *)malloc(sizeof(node));
s->info=x;
p2->next=s;
p2=s;
scanf("%d",&x);
}
if(p2) p2->next=NULL;
return(head);
}