Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <string.h>
- #include <stdlib.h>
- struct Employee{
- char firstName[256];
- char lastName[256];
- int age;
- int sinNumber;
- char status;
- };
- struct Node{
- struct Employee employee;
- struct Node *next;
- };
- void initilizeList(struct Node* _head){
- _head = (struct Node*) malloc(sizeof(struct Node));
- //_head->employee = initEmployee
- }
- void addEmployee(struct Node* _head, char _firstName[256], char _lastName[256], int _age, int _sinNum, char _status){
- struct Node *newNode;
- newNode = (struct Node*)malloc (sizeof(struct Node));
- newNode->next =NULL;
- //initilizes the new node with the employee data
- strcpy(newNode->employee.firstName, _firstName);
- strcpy(newNode->employee.lastName, _lastName);
- newNode->employee.age = _age;
- newNode->employee.sinNumber = _sinNum;
- newNode->employee.status = _status;
- //tranverse to the end of the list
- struct Node* current = _head;
- while(current->next !=NULL){
- current = current->next;
- }
- current->next = newNode;
- }
- /*
- int getnode(){
- }
- int removeEmployee(){
- }
- int Reapeated(){
- }
- int DeleteExpt(){
- }*/
- void displayList1(struct Node* _head, int _age){
- }
- void displayList2(struct Node* _head, char _status){
- }
- int main (){
- struct Node *head;
- head = (struct Node*) malloc (sizeof(struct Node));
- //initilizeList(head);
- int age;
- int sinNum;
- char firstName [256];
- char lastName [256];
- char status;
- for (int i =1;;i++){
- printf("Enter the first name of Employee #%d. Enter 'q' to stop entering employees.\n", i);
- scanf("%s", firstName);
- if (firstName == "q")
- break;
- printf("Enter his/her last name.\n");
- scanf("%s", lastName);
- printf("Enter his/her age\n");
- scanf("%d", &age);
- printf("Enter his/her SIN number\n");
- scanf("%d", &sinNum);
- printf("Enter the status of the employee 'a' active, 's' suspended, 't' terminated.\n");
- status = getchar();
- //scanf("%c", &status);
- addEmployee(head, firstName, lastName, age, sinNum, status);
- }
- displayList1(head, 50);
- displayList2(head, 'a');
- return 0;
- }
Add Comment
Please, Sign In to add comment