Read the images and generate the same output! DO NOT CHANGE THE CMSC 2 5 7 -
Question:
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;
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill