作业帮 > 综合 > 作业

是C语言void create(dictionary **head)void create(dictionary **h

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/12 17:30:53
是C语言void create(dictionary **head)void create(dictionary **head){ if((*head=(dictionary*)malloc
是表示什么意思呢
malloc是c语言中分配内存的函数.你是不是创建链表?头结点要申请一块内存进行存储数据的,
再问: void create(dictionary **head){ if((*head=(dictionary*)malloc(sizeof(dictionary)))==NULL){ printf("ERROR!\n"); exit(-1);} (*head)->Item=NULL; (*head)->length=0;}这个具体的意思是什么呢/
再答: 意思就是首先给节点申请一个空间,然后将该节点下的Item数据(应该是个指针)赋值为空指针,然后将length数据的值赋值为0。后面就可以按照你自己的意思使用该节点了
再问: 谢谢,那 item->next=p->next在程序代码中表示什么?
再答: item也是一个机构体吧,里面的next应该是一个指针,是保存下一个节点的地址。item->next=p->next也就是把p的next值赋值给item的next值,