填空题
下面程序中函数creat用于建立一个带头结点的单向链表,新产生的结点总是插在链表的末尾,单向链表的头指针作为函数值返回。将程序补充完整。
#include<stdiao.h>
struct list
{char data; struct list * next;};
struct list * creat()
{
struct list *h,*p,*q; char ch;
h= 【18】 malloc(sizeof(struct list));
p=q=h;ch=getchar();
while(ch!=’’)
{
p= 【19】 malloc(sizeof(struct list));
p->data=ch;q->next=p;q=p;ch=getchar();
}
p->next=’\0’;
【20】 ;
}
【参考答案】
[18](struct list *)