【发布时间】:2019-01-24 13:41:25
【问题描述】:
一般来说,我知道一个指针存储了另一个位于计算机内存中的值的内存地址,例如:
int firstvalue= 5
int * p1;
p1 = &firstvalue; // p1 = address of firstvalue
如果我们在链表中定义如下操作会发生什么? *current=*list是不是表示current指向的值等于list指向的值?如果我们定义ecur=current,这意味着什么?
int function(struct list_t **list){
struct list_t *ecur=NULL;
struct list_t *current=*list;
ecur=current;
}
更新:
*list=remove(*list, param1, param2) 有什么作用?为什么会这样?
remove 是一个返回修改后的list 列表的函数。
更新 2:
为什么我们需要定义一个指向指针的指针才能修改列表? *list是指向指针的指针吗?
【问题讨论】:
-
current将指向*list指向的任何内容。ecur将指向cur指向的任何内容。 -
ecur=cur表示您没有正确输入current,因此您会收到编译器错误。 -
@StoryTeller,抱歉打错了。已编辑。
-
ecur = current;就像任何其他变量赋值一样。它赋予两个变量相同的值,因此它们都指向同一个地方。 -
@Someprogrammerdude 感谢您的回复,
*list=*list_2有什么作用?
标签: c pointers linked-list