Need Help ?
Have a Question ?

(Solved): Prelab: Week Of February 24th For This Week The Goal Is To Get More Familiar With The Use Of Structs ...

Prelab: Week of February 24th For this week the goal is to get more familiar with the use of structs. Well assume the follow

code in c please
Prelab: Week of February 24th For this week the goal is to get more familiar with the use of structs. We'll assume the following Employee data type: typedef struct { int ID, jobType; float salary; } Employee; Now implement the following function: Employee * readEmployeeInfo (FILE *fp, int *numElems) which returns an array of Employee structs similarly to what you've done before where you can assume an integer at the beginning telling you how many records follow, which tells you how big the array needs to be. (You should feel free to eliminate the second parameter if you want to implement with a getSize function instead -- which would also allow a parameter to be eliminated from the following function.) Each record will consist of two integers and a float corresponding to the members of the Employee struct. This is just like the prelab for Lab 2 except that instead of creating an array of floats you'll be creating an array of Employee structs. Okay, so after readEmployeelnfo is called the user will have an array of Employee records. The following function is useful if the user wants to retrieve the record of a particular employee based on her/his employee ID: Employee * get EmployeeByID (Employee *, int numEmps, int ID) where the first two parameters are the array of employees and the number of employees, and the third parameter is the employee ID. The function returns a pointer to the record (i.e., address of an array element struct) for the employee with that ID. Note that this just requires a loop to find the employee with the specified ID. What do you do if there is no employee with that ID? Now you need to implement get and set interface functions: void setID (Employee *p, int id) int getID (Employee *p) void set Salary (Employee *p, float salary) etc. It's important to understand why such functions are needed: They ensure that users never have to directly access any member of the Employee struct. Suppose we did allow users to access the members directly, then what would happen to their programs if we later change the member "ID" to "employeeID"?

Expert Answer

Program Files: Program.c #include <stdio.h> #include <stdlib.h> typedef struct { int ID; int jobType; float salary; } Employee; // Function Prototypes Employee * readEmployeeInfo(F
We have an Answer from Expert Buy This Answer $6