Advertisement
Guest User

C problems

a guest
May 24th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.16 KB | None | 0 0
  1. main.c
  2. #include "management.h"
  3. int main(){
  4.   int menu=1;
  5.   while(menu>-1){
  6.     printf("Insert choice: \n");
  7.     printf("1) Add employee.\n");
  8.     printf("2) List employees.\n");
  9.     printf("3) Delete employees.\n");
  10.     scanf("%d", &menu );
  11.     switch (menu) {
  12.       case 1:
  13.         addEmployee();
  14.         break;
  15.       case 2:
  16.         listEmployee();
  17.         break;
  18.       case 3:
  19.         deleteEmployee();
  20.         break;
  21.       default:
  22.         printf("Exiting..\n" );
  23.     }
  24.   }
  25.   return 0;
  26. }
  27. ##################################################àà
  28. management.c
  29. #include "management.h"
  30. FILE *file = NULL;
  31. employee *inizializeEmployee(){
  32.   employee *new = (employee*)malloc(sizeof(employee));
  33.   insertName(new->name);
  34.   insertBirth(new->birthDate);
  35.   insertDateOfEmployment(new->dateOfEmployment);
  36.   new->salary=insertSalary();
  37.   return new;
  38. }
  39.  
  40. void addEmployee(){
  41.   int choice=0;
  42.   printf("Adding a new employee\n");
  43.   employee *new=inizializeEmployee();
  44.   printf("A new employee was addedd.\n");
  45.   return;
  46. }
  47.  
  48. void insertDateOfEmployment(char string[]){
  49.   puts("Insert employee's date of employment with the following format: 'YYYY-MM-DD'");
  50.   fgets(string,12,stdin);
  51.   return;
  52. }
  53. void insertBirth(char string[]){
  54.   puts("Insert employee's birth date with the following format: 'YYYY-MM-DD'");
  55.     fgets(string,12,stdin);
  56.   return;
  57. }
  58. void insertName(char string[]){
  59.   puts("Insert employee's name with the following format: 'Surname Name'");
  60.     fgets(string,50,stdin);
  61. }
  62. double insertSalary(){
  63.   double salary=0;
  64.   printf("Insert salary with the following format: '1234.00'\n");
  65.   scanf("%lf",&salary);
  66.   return salary;
  67. }
  68. ###########################################
  69. management.h
  70.  
  71. #include <stdlib.h>
  72. #include <stdio.h>
  73. #include <time.h>
  74. #include <string.h>
  75.  
  76. typedef struct employee{
  77.   char name[50];
  78.   char birthDate[12];
  79.   double salary;
  80.   char dateOfEmployment[12];
  81. }employee;
  82.  
  83. employee *inizializeEmployee();
  84. void addEmployee();
  85. void listEmployee();
  86. void deleteEmployee();
  87. void spacing();
  88. void insertName(char []);
  89. double insertSalary();
  90. void insertBirth(char string[]);
  91. void insertDateOfEmployment(char string[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement