Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Removes an (single?) employee of the given lastName or SIN number
- void removeEmployee(struct Node** head, char firstName [256], int sinNum){
- if (*head == NULL)
- return;
- struct Node* current = *head;
- struct Node* temp;
- if (current->employee->sinNumber == sinNum || strcmp(current->employee->firstName){
- *head = (*head)->next;
- }
- while(current->next!=NULL){
- //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
- if (current->next->employee->sinNumber == sinNum || strcmp(current->next->employee->firstName, firstName) == 0){
- temp = current->next; //holds the node to be freed
- current->next = current->next->next; //deletes the employee
- free(temp->employee);
- free(temp);
- }
- //only if you don't delete an employee
- else{
- current = current ->next;
- }
- }
- }
Add Comment
Please, Sign In to add comment