Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main.c
- #include "management.h"
- int main(){
- int menu=1;
- while(menu>-1){
- printf("Insert choice: \n");
- printf("1) Add employee.\n");
- printf("2) List employees.\n");
- printf("3) Delete employees.\n");
- scanf("%d", &menu );
- switch (menu) {
- case 1:
- addEmployee();
- break;
- case 2:
- listEmployee();
- break;
- case 3:
- deleteEmployee();
- break;
- default:
- printf("Exiting..\n" );
- }
- }
- return 0;
- }
- ##################################################àà
- management.c
- #include "management.h"
- FILE *file = NULL;
- employee *inizializeEmployee(){
- employee *new = (employee*)malloc(sizeof(employee));
- insertName(new->name);
- insertBirth(new->birthDate);
- insertDateOfEmployment(new->dateOfEmployment);
- new->salary=insertSalary();
- return new;
- }
- void addEmployee(){
- int choice=0;
- printf("Adding a new employee\n");
- employee *new=inizializeEmployee();
- printf("A new employee was addedd.\n");
- return;
- }
- void insertDateOfEmployment(char string[]){
- puts("Insert employee's date of employment with the following format: 'YYYY-MM-DD'");
- fgets(string,12,stdin);
- return;
- }
- void insertBirth(char string[]){
- puts("Insert employee's birth date with the following format: 'YYYY-MM-DD'");
- fgets(string,12,stdin);
- return;
- }
- void insertName(char string[]){
- puts("Insert employee's name with the following format: 'Surname Name'");
- fgets(string,50,stdin);
- }
- double insertSalary(){
- double salary=0;
- printf("Insert salary with the following format: '1234.00'\n");
- scanf("%lf",&salary);
- return salary;
- }
- ###########################################
- management.h
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <string.h>
- typedef struct employee{
- char name[50];
- char birthDate[12];
- double salary;
- char dateOfEmployment[12];
- }employee;
- employee *inizializeEmployee();
- void addEmployee();
- void listEmployee();
- void deleteEmployee();
- void spacing();
- void insertName(char []);
- double insertSalary();
- void insertBirth(char string[]);
- void insertDateOfEmployment(char string[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement