consider two functions for free()ing a linked list:
void freelist(struct node *root)
struct node *index, *save;
if (root != NULL)
for (index=root; index!=NULL; index=save)
when i call the first function to free the list and then try to print it i get something like:
void freelist(struct node **root)
struct node *save;
if (*root != NULL)
for ( ; *root != NULL; *root = save)
save = (*root)->next;
what's that? the memory addresses of the data in the nodes? but they were freed already.
when trying to printf the list after the call to the second freelist function, i simply get 'Empty List'.
So, why is the output different? which function should i use, or are they both ok?