填空题
以下程序实现带有头结点的单链表的建立,链表中每个结点包含数据域data(字符型)和指针域next,所建立链表的头指针由参数phd传回调用程序。在空格处填入正确内容。
# include<stdio.h>
# include<stdlib, h>
struct node {
char data;
struct node * next;
};
void creatlist( 【18】 )
{
char ch;
struct node * s, * r;
* phd= malloc( sizeof (struct node));
r= * phd;
ch=getchar();
while(ch !=’@’) {
s = malloc(sizeof(struct node));
s->data=ch;
r->next=s;
r=s;
ch= getchar();
};
r->next= 【19】 ;
}
main ( )
{
struct node * head;
head= NULL;
creatlist( 【20】 )
}
【参考答案】
[18]struct node * *phd