- 论坛徽章:
- 0
|
Hi all,
I found the following function, which is used to remove the head of a
linked list.
void RemoveHead(node **head)
{
node *temp;
if (head && *head) { /* Corrected code */
temp = (*head)->next;
free(*head);
*head = temp;
}
}
1. Why is the purpose of 'head' in the 'if' condition? Shouldn't
'*head' suffice?
2. This function has an argument, which is a pointer to a pointer.
Presumably, 'head' is a pointer to '*head', which is another pointer
to the address of the link list head. If 'head' does not point to
NULL, does it follow that '*head' does not point to NULL? If so, why? |
|