| 查看: 413 | 回复: 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; |
» 猜你喜欢
药学硕士,第一、第二作者已发表6 篇 SCI,药理方向及相关方向2026年/2027年博士申请
已经有6人回复
一篇MDPI论文改变了学习工作和生活
已经有5人回复
26年博士申请自荐-电催化
已经有3人回复
中国地质大学(北京)博士招生补录,数理学院材料科学与工程专业和材料与化工专业
已经有6人回复
收到国自然专家邀请后几年才会有本子送过来评
已经有4人回复
考博
已经有5人回复
26年申博自荐-计算机视觉
已经有4人回复
药化及相关博士的申请
已经有3人回复

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

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












;
回复此楼