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* prev = current;
- struct Node* temp = NULL;
- do{
- //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->employee->sinNumber == sinNum || strcmp(current->employee->firstName, firstName) == 0){
- //current node is the head
- if (current == *head){
- temp = *head;
- *head = (*head)->next;
- }
- //current node is the tail
- else if (current->next = NULL){
- temp = currnet;
- prev ->next = NULL;
- }
- //current node is in the middle
- else {
- temp = current; //holds the node to be freed
- prev->next = current->next; //deletes the employee
- }
- }
- free(temp->employee);
- free(temp);
- prev = current;
- current = current->next;
- }while(current->next!=NULL);
- }
Add Comment
Please, Sign In to add comment