struct node{ int data; struct node *next; }; void removeNodeWithData(struct node **head, int removeData) { struct node *current = *head; struct node *prev=*head; while(current->data == removeData) //head { *head = (*head)->next; free(current); current = *head; } prev = *head; current = (*head)->next; while(current != NULL) { if(current->data == removeData) { prev->next = current->next; free(current); } else{ prev = current; } current = prev->next; } }
Remove Node with Key
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment