| 查看: 492 | 回复: 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; |
» 猜你喜欢
广西大学-广州大学招聘博士后 欢迎广大优秀人才!!!
已经有11人回复
闲聊
已经有3人回复
江苏省自然基金 什么时候出结果
已经有4人回复
如何查询2026年获批项目名称?
已经有3人回复
两块石头
已经有10人回复
科研人应该花精力去思考如何解决问题,而不是去凝练问题
已经有19人回复
售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急
已经有15人回复
面上没中,邀请各位路过的虫友分析一下分数
已经有13人回复
初秋的晨风
已经有6人回复
Ei源刊怎么投
已经有4人回复


3楼2017-05-06 19:49:41
2楼2017-05-03 21:10:52










;
回复此楼
