Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C Using struct.c as a starting point, implement an application that creates a database of employee records. Your implementation will need to: Define the

in C

Using struct.c as a starting point, implement an application that creates a database of employee records. Your implementation will need to:

  • Define the structure PERSON, in a header file called person.h, which you will need to create in the src directory.
    • The struct's contents are in the C tutorial slides.
    • A typedef should be used to reference the stucture as PERSON instead of as struct person.
  • Create an employees array (an array of PERSON *s) in the main file (struct.c)
  • In a new file, person.c, implement functions:
    • addEmployee : reads personnel data from the standard input, populates an element in the employees array.
    • displayEmployee : takes as input a pointer to a PERSON and displays (i.e. prints) the information for that person in a readable format.
    • displayAllEmployees : to display all employees in the array (by calling displayEmployee on each element.
  • Finally, the main program (in struct.c) which will need to:
    • Prompt first for the number of employees.
    • Create the employees array with the correct size.
    • Call addEmployee the specified number of times.
      • You will first need to allocate space for a PERSON, and store the resulting PERSON * in the employees array.
    • Call displayAllEmployees.
    • Free all allocated space.

Here are the signatures of the functions that must be declared in person.h and defined in person.c:

void addEmployee(PERSON *employee); void displayEmployee(PERSON *employee); void displayAllEmployees(PERSON *employees[], int numberOfEmployees); 

Don't forget:

  • Include person.h in both person.c and in struct.c so person.c can define the functions declared in person.h and so struct.c can reference those functions.
  • Add person.c to the struct executable in CMakeLists.txt, so the definitions from person.c are available when the executable is compiled.

A sample run might look like:

How many employees? 4 Enter information for the next employee. Name : Bob Ross Age : 54 Height : 1.2 Birthday ( MM / DD / YYYY ) : 11/22/3333 Enter information for the next employee. Name : Idk someone with a name Age : 980 Height : 18.5 Birthday ( MM / DD / YYYY ) : 13 / 37 / 1337 Enter information for the next employee. Name : Arnold Shwa... how2spell Age : 72 Height : 180.3 Birthday ( MM / DD / YYYY ) : 7 / 30 / 1947 Enter information for the next employee. Name : yes Age : 1 Height : 1 Birthday ( MM / DD / YYYY ) : 1/1/1 Displaying Employees... Bob Ross : Age : 54 Height : 1.2 Birthday : 11/22/3333 Idk someone with a name : Age : 980 Height : 18.5 Birthday : 13/37/1337 Arnold Shwa... how2spell : Age : 72 Height : 180.3 Birthday : 7/30/1947 yes : Age : 1 Height : 1.0 Birthday : 1/1/1 Process finished with exit code 0

#include  struct birthday { int month; int day; int year; }; int main(void) { struct birthday myBday; // - no new needed ! // then, use dot notation like in Java ! */ scanf("%d/%d/%d", &myBday.month, &myBday.day, &myBday.year); printf("I was born on %d/%d/%d ", myBday.month, myBday.day, myBday.year); return 0; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions

Question

1. What is Ebola ? 2.Heart is a muscle? 3. Artificial lighting?

Answered: 1 week ago