java 链表指针_链表上的指针问题

作为C中的大多数初学者,我正在实现一个简单的链表 .

列表的每个节点都定义如下:

typedef struct list_node {

void * data;

struct list_node * next;

} list_node_t;

我制作了一个测试程序来创建和迭代列表 . 创建和插入操作正常工作 . 但是,下面的代码给了我一些问题:

list_node_t * node = NULL;

list_iter_reset(list, node);

if (node == NULL) {

printf("Node is NULL.\n");

} else {

printf("Node is not NULL.\n");

}

fflush(stdout);

函数 list_iter_reset() 定义如下 . 请注意 list->head 不指向NULL,因为我之前在列表中插入了节点 .

void list_iter_reset(list_t list, list_node_t * node)

{

node = list->head;

if (node == NULL) {

printf("Node is NULL.\n");

} else {

printf("Node is not NULL.\n");

}

fflush(stdout);

}

执行该代码的输出如下:

Node is not NULL.

Node is NULL.

由于我将指向节点的指针传递给函数,为什么测试程序中创建的节点在该函数调用后仍然指向NULL?

我猜这里有一个简单的指针算术方面 . 我一直在环顾四周,找不到类似的问题 .

先感谢您 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值