Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DeleteElement(Node **head, char *director)
- {
- if (*head == NULL)
- {
- printf("The list is empty!\n");
- return;
- }
- Node *current = *head;
- Node *previous = NULL; //For 1st node, indicate there is no previous.
- while (current != NULL)
- {
- if (strcmp(director, current->data.producer) == 0)
- {
- if (previous == NULL)
- {
- *head = current->next;
- }
- else
- {
- previous->next = current->next;
- }
- free(current);
- printf("Елемента е изтрит успешно.\n");
- current = *head;
- }
- else
- {
- previous = current;
- current = current->next;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment