以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转储到链表的各个结点中,请从与下画线处号码对应的一组选项中选择正确的选项。
#include <stdio.h>
struct node
char data; struct node *next; ;
(48) CreatList(char *s)
struct node *h, *p, *q;
h=(struct node *)malloc(sizeof(struct node));
p=q=h;
while (*s!=’\0’ )
p=(struct node *)malloc(sizeof(struct node));
p->data= (49) ;
q->next=p;
q= (50) ;
s++;
p->next=’\0’;
return h ;
main()
char str[]="link list";
struet node *head ;
head=CreatList(str) ;
…
A.char *
B.stmct node
C.struct node*
D.char
参考答案:C
解析: 很显然在此处需要填入的是函数的返回类型,因此我们看函数最后的return语句,该语句为return h,而在函数中,我们再找到h的定义,发现h被定义为struct node*的形式,因此,该函数的返回类型是node型的结构体变量,因此为struct node*。