Guest User

Untitled

a guest
Jan 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.12 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. struct Employee{
  6.     char firstName[256];
  7.     char lastName[256];
  8.     int age;
  9.     int sinNumber;
  10.     char status;
  11. };
  12.  
  13. struct Node{
  14.     struct Employee employee;
  15.     struct Node *next;
  16. };
  17.  
  18. void initilizeList(struct Node* _head){
  19.     _head = (struct Node*) malloc(sizeof(struct Node));
  20.     //_head->employee = initEmployee
  21.  
  22. }
  23.  
  24. void addEmployee(struct Node* _head, char _firstName[256], char _lastName[256], int _age, int _sinNum, char _status){
  25.     struct Node *newNode;
  26.     newNode = (struct Node*)malloc (sizeof(struct Node));
  27.     newNode->next =NULL;
  28.  
  29.     //initilizes the new node with the employee data
  30.     strcpy(newNode->employee.firstName, _firstName);
  31.     strcpy(newNode->employee.lastName, _lastName);
  32.     newNode->employee.age = _age;
  33.     newNode->employee.sinNumber = _sinNum;
  34.     newNode->employee.status = _status;
  35.  
  36.     //tranverse to the end of the list
  37.     struct Node* current = _head;
  38.     while(current->next !=NULL){
  39.         current = current->next;
  40.     }
  41.     current->next = newNode;
  42.    
  43.  
  44. }
  45. /*
  46. int getnode(){
  47.  
  48.  
  49. }
  50.  
  51. int removeEmployee(){
  52.  
  53.  
  54.  
  55. }
  56.  
  57. int Reapeated(){
  58.  
  59.  
  60. }
  61.  
  62. int DeleteExpt(){
  63.  
  64.  
  65. }*/
  66.  
  67.  
  68. void displayList1(struct Node* _head, int _age){
  69.  
  70.  
  71.  
  72.  
  73. }
  74.  
  75. void displayList2(struct Node* _head, char _status){
  76.  
  77.  
  78.  
  79.  
  80.  
  81. }
  82.  
  83.  
  84. int main (){
  85.     struct Node *head;
  86.    
  87.     head = (struct Node*) malloc (sizeof(struct Node));
  88.     //initilizeList(head);
  89.  
  90.     int age;
  91.     int sinNum;
  92.     char firstName [256];
  93.     char lastName [256];
  94.     char status;
  95.  
  96.     for (int i =1;;i++){
  97.         printf("Enter the first name of Employee #%d. Enter 'q' to stop entering employees.\n", i);
  98.         scanf("%s", firstName);
  99.         if (firstName == "q")
  100.             break;
  101.         printf("Enter his/her last name.\n");
  102.         scanf("%s", lastName);
  103.  
  104.         printf("Enter his/her age\n");
  105.         scanf("%d", &age);
  106.  
  107.         printf("Enter his/her SIN number\n");
  108.         scanf("%d", &sinNum);
  109.  
  110.         printf("Enter the status of the employee 'a' active, 's' suspended, 't' terminated.\n");
  111.         status = getchar();
  112.         //scanf("%c", &status);
  113.         addEmployee(head, firstName, lastName, age, sinNum, status);       
  114.     }
  115.  
  116.     displayList1(head, 50);
  117.     displayList2(head, 'a');
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.     return 0;
  125. }
Add Comment
Please, Sign In to add comment