Before this is marked as a dup, I have read
In C, what does a variable declaration with two asterisks (**) mean?
I don't understand the implementation of inserting a new node in linked list
And I still am struggling with the logical steps of the double asterisk. I understand that in a linked list I need to create a new node, dynamically allocate space for it and then relabel the new node as the head.
I just don't understand the logical steps of the function between the &head
and the double asterisk. What is pointing to what and how does the implementation of the double asterisk work here?
void push(struct node** head_ref, int new_data)
{
struct node* new_node = (struct node*)malloc(sizeof(struct node));
new_node->data = new_data;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}
push(&head, 2);