I have been encountering a lot of linked list functions and C functions that intend to pass double pointer in place of single pointer to a function.For example this below function for sorted insert in a linked list :
void sortedinsert(struct node **headref,struct node *newnode)
{
while(*headref!=NULL&&(*headref)->data<newnode->data)
headref=&((*headref)->next);
newnode->next=headref;
*headref=newnode;
}
Please explain me about the use of double pointers as function arguments in place of single pointers and how does it eases of writing functions as above for linked lists?