为什么不是struct node *而是struct node **大神帮忙

struct node
14
{
15
int data;
16
struct node* next;
17
};
18

19
/* 反转单链表. 分别用3个指针,指向前一个,当前,下一个 /
20
static void reverse(struct node
* head_ref)
21
{
22
struct node* prev = NULL;
23
struct node* current = head_ref;
24
struct node
next;
25
while (current != NULL)
26
{
27
next = current->next;
28
current->next = prev;
29
prev = current;
30
current = next;
31
}
32
head_ref = prev;
33
}
oid printList(struct node *head)
48
{
49
struct node *temp = head;
50
while(temp != NULL)
51
{
52
printf("%d ", temp->data);
53
temp = temp->next;
54
}
55
}
为什么不是struct node *而是struct node *
,第二个函数为什么又是,就这个很糊涂,大神帮忙

一般来说, 初始化链表之类的需要双指针(这里翻转链表因为不是在原始链表上翻转,而是返回新的链表头,所以也需要双指针)
像求链表长度、插入节点、打印输出就只要单指针。

 使用struct node **的目的是,这个函数内部需要改变这个指针参数,并且要作用到调用者上
*head_ref = prev;

使用struct node *,只是函数内需要使用这个指针,无需改变它。

c语言中要通过传参改变构造体类型的的值时,只能通过传入指针,通过指针进行改变。
先定义一个结构体
struct node
{
int element;
};

int main()
{
                struct node *p = (struct node*)malloc(sizeof(struct node));     //在主函数中创建一个头结点

                //chang_node()  在该函数里面创建一个新结点,将p重新指向这个新的结点,这个时候就需要传入 struct node **
                change_node(&p);                                                                          
}

void change_node(struct node ** temp)
{
                struct node *p = (struct node *)malloc(sizeof(struct node));
                *temp = p;                                    //这句实现将传入的指针指向新创建的结点
}

一般链表只有在会修改头结点的函数,才会传struct node **;

可以理解为指针的指针吗?