Question
Read the images and generate the same output! DO NOT CHANGE THE CMSC 2 5 7 - P 2 . C file. This is the
Read the images and generate the same output! DO NOT CHANGE THE CMSCPC file. This is the psupport.c file:#define GNUSOURCE strcasestr is a nonstandard GNU extension,
we need this line while serching for matching last name
#include
#include
#include
#include psupport.h
void createrecord specify parameters. Clues are in the initalize function.
define function. Clues are in the initalize function
do not forget to increase total number of employees in the database
void printtitle you can keep this fuction or remove if needed
printf No ID Name Email Salary Hire Date
;
printf
;
fix save function. Save array into file: databaseupdated in the same format with the
database file.
void save dataBaseptr db this function is for saving the database into a text file
FILE dbfu;
dbfu fopen databaseupdated", w;open an Std IO file to write into
if dbfu NULL
printf File cannot be created";
return;
for int i ; i dbtotal; i
fprintf dbfuadd format specifiers here, dbempiID
add other members;
fclose dbfu;close file after writing
return;
void displaymenu struct DataBase db
int input ;
while input
puts
;
printf
Employee Database Total Employees: d
;you need to fix this line so that total employees in the database is printed
puts
;
puts Choose one of the menu options below:";
puts Sort by ID;
puts Sort by Hire Date";
puts Display all employees";
puts Search employees by ID;
puts Search employees by Last Name";
puts Delete employee by ID;
puts Save";
puts Exit";
scanf d &input;
switch input
case :
call the function you defined for sorting by ID
break;
case :
call the function you defined for sorting by Hire Date
break;
case :
call the function you defined for displaying employees
break;
case :
call the function you defined for searching employees by ID
break;
case :
call the function you defined for searching employees by Last Name
break;
case :
call the function you defined for deleting employee by ID
break;
case :
save db;
break;
case :
free all allocated memory
printfBye
;
break;
This is the psupport.h file:
File : psupport.h
Description : Header file for project
#ifndef PHeader To prevent double inclusion of header
#define PHeader To prevent double inclusion of header
#include
#define byID
#define byNAME
#define dbSIZE
#define idSIZE
#define nameSIZE
#define emailSIZE
typedef struct date do not modify
int day;
int month;
int year;
date;
typedef struct Employee
char IDidSIZE;
declare other members
employeeemployeeptr;
typedef struct DataBase
a pointer to first element of empoloyee array
number of employees in database
dataBaseptr;
Functional Prototypes
Function : initialize
Description : This function creates an array in the database
then initalializes each array elemet with the data
in the given file
Inputs : a pointer to DataBase struct
Output : none
void initialize dataBaseptr;
Write formal comments for each function header.
In the same format with the initialize function
void createrecord ;specify parameters types. Clues are in the initalize function.
void printtitle ;
void displaymenu dataBaseptr;
other function headers here
void savedataBaseptr;
#endif To prevent double inclusion of header This is the CMSCpc fileDO NOT CHANGE: #include
#include
#include
#include psupport.h
FILE dbf;File structure for Standard IO
int main int argc, char argv
dbf NULL;
Read file if a file name is entered
ifargc
dbf fopen argvr;
Read database file if no file name is entered
else if argc
dbf fopen databaser;
else
printfProgram can read one file only at a time";
if dbf NULL
printfFile does not exist.
Enter a valid file name when running the program. Such as: p database";
return ;
struct DataBase db;
db mallocsizeofstruct DataBase;
initialize db;
displaymenudb;
Metafclose dbf;close file
return ;
void initialize struct DataBase db
dbemp malloc sizeof struct Employee;
dbtotal ;
char IDidSIZE;
char firstnamenameSIZE;
char lastnamenameSIZE;
char emailemailSIZE;
double salary;
char line;
date hiredate;
for ;;
fgets line dbf;get a line from the file
sscanf lines s s s lf ddd
ID firstname, lastname, email, &salary, &hiredate.month, &hiredate.day, &hiredate.year;
createrecordID firstname, lastname, email, salary, hiredate, db;
if feof dbf
break;
a !!! !!! docs.google.com VEIKOUS 10-f...t Lowes.com Bing Outsunny Vin...t Lowes.com Copy of project2 .DOCX File Edit View Insert Format Tools Help A100% Normal... . 5 VCU 5 2 fotobudo betod dedecke besedestakaaban 0 0 0 Time... Create a Makefile to build your program. 0 Copy of project2 .DOCX File Edit View Insert Format Tools Help A100% Headin... Step 2: Define a structure with the tag name Employee (within p2-support.h), with the following members: ID (ID): a character string with a size of 6 First Name (first_name): a character string with a size of 10 Last Name (last_name): a character string with a size of 10 Email address (email): a character string with a size of 20 Employee Salary (salary): a double type. Hire Date (hire_date): a date type. (use the date type given in the header file.) Then your "DataBase" struct should be defined (within p2-support.h) as: A dynamic array of employees. (Note that you cannot declare a dynamic array within the struct definition. You only need to create a pointer to point to the dynamic array within the definition. The array is already allocated within the initialize function) A variable to hold the number of current employees in the database (type of int). Read all comments in the file carefully. There are hints and instructions. 12 + B VEIKOUS 10-f...t Lowes.com Bing Outsunny Vin...t Lowes.com Copy of... Print Formatting Displaying Menu: Time... Step 3: Implement functions for displaying the main display_menu the menu in the p2-support.c file, add headers for functions into the p2-support.h file. I 3 14 + Displaying employees (Menu item 3): No: 3 characters left aligned UA B I U docs.google.com Menu title: 62 charters long Total employees should always be printed as right aligned and 3 characters. 0 A C 0 4 de you are intsheu'check the lo camint section to prepart and the thes to desdotmined. **** Employee Database - Total Employees: 010 ********** C Outsunny 9.7...at Lowes.com 2 M ID: 5 characters, right aligned and zero filled. Name: Limited to 13 characters, first name, and last name is combined when printing. Truncate to 13 characters if needed. But, do not change the original database. Salary: 10 characters. The first character is always a $ sign. The salary amount is right aligned with two digits after the decimal point. I + IMDb Share Share A A !!! VEIKOUS 10-f...t Lowes.com Bing Outsunny Vin...t Lowes.com Copy of project2 .DOCX File Edit View A ........ e V Insert Format Tools Help 100% - Headin... - Anmmmm 7. Save 8. Exit 1 >> EIKOUS 10-f...t Lowes.com MM of project2 .DOCX Edit View A 100% - Choose one of the menu options below: 1. Sort by ID 2. Sort by Hire Date 3. Display all employees 4. Search employees by ID 5. Search employees by Last Name 6. Delete employee by ID 7. Save 8. Exit Step 3: Implement functions for displaying the main display_menu the menu in the p2-support.c file, add headers for functions into the p2-support.h file. Read all comments in the file carefully. There are hints and instructions. The main menu of your program should print as follows: *** Employee Database Total Employees: 0101 Insert Format Tools Help Headin... Note that there is an integer indicating the number of employees in the title. Following is the description of each menu option: Bing Time... - 1. Sort records with ID numbers from lowest to highest. 2. Sort records with hire date from earliest to most recent. 3. Display all records as ordered in the database. 4. Display the employee with the given ID. Will print a message if an employee with a given ID does not exist. 5. Search the database by last name and display employee(s) partially or completely matching with the given string. This option may result in multiple hits; for example, there might be more than one entry with the same last name but a different first name. 6. Delete one record with the matching ID from the list. Print a message if no match. 7. Save the database to another file named as database_updated. 8. Exit the program. It should also deallocate all dynamically allocated memory. Part of the program is given to simplify your job: Employee Database Name Choose one of the menu options below: 1. Sort by ID 2. Sort by Hire Date 3. Display all employees Time... ......... 4. Search employees by ID 5. Search employees by Last Name 6. Delete employee by ID 7. Save 8. Exit. 3 No. ID 00001 Chris Boyle 00002 Paul Green. 00003 Wei Martin 00006 Chris Reddy. Email Outsunny Vin...t Lowes.com 2 Total Employees: 010 6 14 + docs.google.com 14 + B I UA Salary docs.google.com Hire Date --/--/---- cb@vcu.edu $200000.01 01/08/2023 pg@vcu.edu $ 2700.45 08/05/2022 wm@vcu.edu $ 98999.99 01/10/2023 cr@vcu.edu. $ 23040.67 07/08/2022 00007 Mitch Martine mitch@vcu.ed $ 78999.88 12/15/2022 00000 Duid Deu $100000 01 1110 (2000 B I U I A 6 20 + Share + Shar A a = ||| Q !!! VEIKOUS 10-f...t Lowes.com Copy of project2.docx... Copy of project2.DOCX File Edit View Insert Format Tools Help. 5 d A 0 I A 100% - Headin... 14 + B I fututzw. A...... 7. Save 8. Exit 3 No. ID 7 --/--/---- 6 00014 Christine Blu cb@vcu.edu $40009.99 12/20/2022 8 Choose one of the menu options below: 1. Sort by ID 2. Sort by Hire Date. 3. Display all employees 4. Search employees by ID 5. Search employees by Last Name. 6. Delete employee by ID Bing 8. Exit 16 Name Employee Database - Total Employees: 009 ID Hire Date --/--/---- 00001 Chris Boyle cb@vcu.edu $200000.01 01/08/2023 00002 Paul Green pg@vcu.edu $ 2700.45 08/05/2022 00003 Wei Martin. wm@vcu.edu $ 98999.99 01/10/2023 10000 DETEUTEGES 00007 Mitch Martine mitch@vcu.ed $ 78999.88 12/15/2022 $100000.01 11/10/2022 $ 23040.67 01/01/2020 $40009.99 12/20/2022 $ 1000.37 10/25/2022 8500.01 01/09/2023 00008 David Boyle db@vcu.edu. 00009 Chris Magenta cj@vcu.edu 00014 Christine Blu cb@vcu.edu 00015 Paula Brown. pb@vcu.edu. 00105 Stephen Black sb@vcu.edu $ 6 Time... Choose one of the menu options below: 1. Sort by ID 2. Sort by Hire Date 3. Display all employees 4. Search employees by ID Outsunny Vin...t Lowes.com 5. Search employees by Last Name 6. Delete employee by ID 7. Save chegg can't post more... Name VEIKOUS 10-f...t Lowes.com Email Employee Database Total Employees: 009 Enter the Last Name you are searching for ma Salary Hire Date --/--/---- 00003 Wei Martin. wm@vcu.edu. $ 98999.99 01/10/2023 00007 Mitch Martine mitch@vcu.ed $ 78999.88 12/15/2022 00009 Chris Magenta cj@vcu.edu $ 23040.67 01/01/2020 Name Bing Y Email Copy of project2.DOCX File Edit View Insert Format Tools Help. Headin... A 100% - t...... bost by t 2. Sort by Hire Date 3. Display all employees 4. Search employees by ID 5. Search employees by Last Name: 6. Delete employee by ID. 7. Save 8. Exit docs.google.com Salary Time.... Enter the ID you are searching for 14 No. ID Email Outsunny Vin...t Lowes.com 7 docs.google.com Choose one of the menu options below: 1. Sort by ID 2. Sort by Hire Date. 3. Display all employees 4. Search employees by ID 5. Search employees by Last Name 6. Delete employee by ID 14 + Salary --/--/---- 00014 Christine Blu cb@vcu.edu $40009.99 12/20/2022 B I 4 fuurl. Employee Database - Total Employees: 009 Hire Date U A 5mm 0 6 + Copy of project2.docx... D + Share Share 0 B G A A A
Step by Step Solution
There are 3 Steps involved in it
Step: 1
It seems like you have provided the code for the files p2supportc and p2supporth but there are some ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started