Guest User

Untitled

a guest
Jan 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. //Removes an (single?) employee of the given lastName or SIN number
  2. void removeEmployee(struct Node** head, char firstName [256], int sinNum){
  3.     if (*head == NULL)
  4.         return;
  5.     struct Node* current = *head;
  6.     struct Node* prev = current;
  7.     struct Node* temp = NULL;
  8.     do{
  9.         //if one of the other is true don't need to check which one the user wants to use because they will not equal anywyas
  10.         if (current->employee->sinNumber == sinNum || strcmp(current->employee->firstName, firstName) == 0){
  11.             temp = current; //holds the node to be freed
  12.             prev->next = current->next; //deletes the employee
  13.             free(temp->employee);
  14.             free(temp);
  15.         }
  16.         prev = current;
  17.         current = current->next;
  18.     }while(current->next!=NULL);
  19. }
Add Comment
Please, Sign In to add comment