问题 单项选择题

以下程序的功能是:建立一个带有头结点的单向链表,并将存储在数组中的字符依次转储到链表的各个结点中,请从与下划线处号码对应的一组选若中选择出正确的选项。#include

stuct node{ char data; struct node *next;}; (1) CreatLis(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= (2) ;

q->next=p; q= (3) ; s++; }

p->next=’\0’; return h;}main(){ char str[]="link list";

struct node *head; head=CreatLis(str); ...}

2()

A.*s

B.s

C.*s++

D.(*++

答案

参考答案:A

解析:

结构体node的数据成员data的类型为char型,而s为传入的字符串.

选择题
多项选择题