hi i have the following code to delete a node from my linked list but it seems that theres something wrong with it. can anyone assist me with this?
Code:/* function to delete a node on list */ void free_used_node(int id) { struct List *list, *temp; list =ListHead; /* points to the 1st node of the list */ /* handles situation if header node id is what we want to delete. */ if(list->id == id) { ListHead = list->next; free(list); } /* if not, loop thru list and find out target */ while(list != NULL) { if(list->next) { if(list->next->id == id) { temp = list->next; list->next = temp->next; free(temp); } } list = list->next; } }