[FONT=sans-serif]Hi everyone, I am currently learning C using KNKing's book. Currently I'm confused by pointers to pointers/linked lists and would like to kindly request for some help and clarifications, with regards to this function below. Thank you all and bless.
The below function will be called with (&first,10), with first being a pointer to the first node in the list and 10 being the value in which the node is to be deleted.
Code:
struct node *delete_from_list(struct node **list, int n)
{
struct node *item = *list;
while (item) {
if (item->value == n) {
*list = item->next;
free(item);
break;
}
list = &item->next;
item = item->next;
}
return *list;
}
my question is. whenver i use the "*list",
*list = item->next;
am i not editing the address which the pointer "first" contains? so when the above statement is executed wont "first" no longer be pointing to the first node? Thank you!