C linked list pointer
I got this code from my cs script and dont understand why Person **anchor in line 20 is a double pointer: void add_first(Person **anchor, Person *person) code: #include <stdio.h> typedef struct Person { char name[10]; int alter; struct Person *next; } Person; Person *create(char *person_name, int person_alter) { Person *neu = ( Person *)malloc( sizeof(Person) ); if ( neu == NULL ) return NULL; strncpy( neu->name, person_name, 9 ); neu->alter = person_alter; return neu; } // but why? void add_first(Person **anchor, Person *person) { person->next = *anchor; *anchor = person; } int main() { Person *liste = NULL; add_first( &liste, create("Max", 18) ); add_first( &liste, create("Lisa", 21) ); add_first( &liste, create("Fritz", 19) ); Person *element = liste; while( element != NULL ) { printf("%-10s (%d Jahre)\n", element->name, element->alter); element = element->next; } return 0; }