Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct node *delete_val(int value, struct node *head) {
- struct node *h1 = head;
- if (head == NULL) { return NULL;}
- if (head->next == NULL) { free(head); return NULL;}
- while (h1 != NULL) {
- if (h1->next != NULL && h1->next->data == value){
- h1->next = h1->next->next;
- } else {
- h1 = h1->next;
- }
- free(h1);
- return head;
- }
- }
Add Comment
Please, Sign In to add comment