I'm doing some C programming exercise questions and am not sure about this one:
Does it matter if we place the "free(node);" statement before the recursive call? Please explain.
Code:
void deleteList(struct contact* node) {
if (node != NULL) {
deleteList(node->next);
free(node);
}
}
I was thinking it does matter because if free(node) were placed above the recursive call it would delete the node and then there would be no connection to the next element of the linked list. Is this correct thinking?
Thanks.