Question: In C programming, create an array that has information about a list of employees from reading an input file. (Should be able to handle different

In C programming, create an array that has information about a list of employees from reading an input file. (Should be able to handle different # of employees, names, etc.)

In C programming, create an array that has information about a list

Files provided: 1) Assignment1.h The file now only contains a comment. You need to an Employee struct in this file. The struct should contain 3 variables. A C-string for the name. You can assume that no name is more than 9 characters long, so this can be a character array of size 10 (to account for the null character). b. An integer for the ID. Each ID is a 6-digit number. A double for the Employee's hourly rate. a. 2) Assignment1 Input.txt. The first line of the file denotes the number of employees. In the sample input this number is 28. Each employee's information is listed on a single line in the following format: "name ID HourlyRate". Assignment1.c #include //For input/output functions. #include //For malloc, free, etc. #include "Assignment1.h" //Include our own header file for the Employee struct. int main() { 1/1. Open the file Assignment1Input.txt and read in the first line of the file to determine how many Employees we need for our array, and use malloc() to dynamically allocate an array of this size. 1/2. Use a loop to read the Employee information from Projecto.txt and write the information to the entries of your array. Suggestion: read a single line of the file using fgets() then use sscanf() to parse out the variables from the line. 1/3. Loop through your array and print out the employee information. Each employee (name, ID, hourly rate) should be on a single line. The name should be left justified in a column of width 10. The IDs are each 6 digits long so they can be printed with a single space after it. The hourly rate should be printed to 2 decimal places. return 0; } Assignment1.h //In this file, write the definition of a struct for an Employee. //An Employee should contain 3 variables: //1. A C-string for the name. You can assume that no name is more than 9 characters long, so this can be a character array of size 10 (to account for the null character). 1/2. An integer for the ID. Each ID is a 6-digit number. //3. A double for the hourly rate. Files provided: 1) Assignment1.h The file now only contains a comment. You need to an Employee struct in this file. The struct should contain 3 variables. A C-string for the name. You can assume that no name is more than 9 characters long, so this can be a character array of size 10 (to account for the null character). b. An integer for the ID. Each ID is a 6-digit number. A double for the Employee's hourly rate. a. 2) Assignment1 Input.txt. The first line of the file denotes the number of employees. In the sample input this number is 28. Each employee's information is listed on a single line in the following format: "name ID HourlyRate". Assignment1.c #include //For input/output functions. #include //For malloc, free, etc. #include "Assignment1.h" //Include our own header file for the Employee struct. int main() { 1/1. Open the file Assignment1Input.txt and read in the first line of the file to determine how many Employees we need for our array, and use malloc() to dynamically allocate an array of this size. 1/2. Use a loop to read the Employee information from Projecto.txt and write the information to the entries of your array. Suggestion: read a single line of the file using fgets() then use sscanf() to parse out the variables from the line. 1/3. Loop through your array and print out the employee information. Each employee (name, ID, hourly rate) should be on a single line. The name should be left justified in a column of width 10. The IDs are each 6 digits long so they can be printed with a single space after it. The hourly rate should be printed to 2 decimal places. return 0; } Assignment1.h //In this file, write the definition of a struct for an Employee. //An Employee should contain 3 variables: //1. A C-string for the name. You can assume that no name is more than 9 characters long, so this can be a character array of size 10 (to account for the null character). 1/2. An integer for the ID. Each ID is a 6-digit number. //3. A double for the hourly rate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!