Guest User

Untitled

a guest
Jan 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 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* temp;
  7.     if (current->employee->sinNumber == sinNum || strcmp(current->employee->firstName){
  8.         *head = (*head)->next;
  9.     }
  10.     while(current->next!=NULL){
  11.         //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
  12.         if (current->next->employee->sinNumber == sinNum || strcmp(current->next->employee->firstName, firstName) == 0){
  13.             temp = current->next; //holds the node to be freed
  14.             current->next = current->next->next; //deletes the employee
  15.             free(temp->employee);
  16.             free(temp);
  17.         }
  18.         //only if you don't delete an employee
  19.         else{
  20.             current = current ->next;
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment