Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct node *delete_contains(int v, struct node *h)
- {
- struct node *t = NULL;
- //if h is EMPTY return
- if (h == NULL)
- {
- return NULL;
- }
- //if we found the data
- if (h->data == v)
- {
- t = h->next;
- free(h);//delete h
- h=NULL;//avoid memory leak
- return t;//return
- }
- else
- {
- // recursive call
- h->next = delete_contains(v, h->next);
- return h;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement