| 查看: 488 | 回复: 2 | |||
elevenleo铁杆木虫 (正式写手)
|
[求助]
C语言结构体方面的问题 已有2人参与
|
|
主程序如下,其中list结构体的定义下面也已给出。我的问题是语句“temp->parent = node;”,按照定义,node应该是指针,而temp->parent应该是结构体的值,为何二者可以彼此赋值。同样后文的“node->child = temp;”也是如此。此外,“node->child->parent = temp;”中连续两个箭头,又是什么意思。最后一个问题,structure中的“struct lists”时怎样的定义,能否详细解释。小弟初来乍到,还望高手不吝赐教,详细解释,不胜感谢。 void insert (list *node, int x) { list *temp; if (node==NULL) { printf("\n Error!! asked to enter after a NULL pointer, hence exiting \n" ;exit(1); } temp = (list *)malloc(sizeof(list)); temp->index = x; temp->child = node->child; temp->parent = node; if (node->child != NULL) { node->child->parent = temp; } node->child = temp; return; } 结构体定义: typedef struct lists { int index; struct lists *parent; struct lists *child; } list; |
» 猜你喜欢
售SCI文章,我:8O.5.5.1O.54,科目全,可十急
已经有5人回复
售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急
已经有5人回复
售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急
已经有3人回复
面上没中,邀请各位路过的虫友分析一下分数
已经有13人回复
售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急
已经有8人回复
两块石头
已经有8人回复
初秋的晨风
已经有6人回复
学科评审组评审是指会评吗?
已经有9人回复
售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急
已经有14人回复
广西大学-广州大学招聘博士后 欢迎广大优秀人才!!!
已经有7人回复

2楼2017-05-03 21:10:52

3楼2017-05-06 19:49:41










;
回复此楼