How do I free a linked list and would the code below be the answer to my question?
Thank you
Code:struct node { int data; struct node* next; }; int main() { struct node* head = NULL; struct node* second = NULL; head = malloc(sizeof(struct node)); second = malloc(sizeof(struct node)); head->data = 1; head->next = second; second->data = 2; second->next = NULL; free(head); return 0; }