Μaintenance and Out-of-Order Time
The maintenance department of an industrial unit keeps a record of damage to the plant\'s mechanical equipment by entering the following information for each piece of equipment (all values are int):
1. Machine code (values 1-20)
2. Category of failure (permitted values 1-10)
3. Number of hours when the item was deactivated (positive number)
The file is serial, given, and has the name maintenance.txt. Some lines of the file are:
45 3 52
3 2 8
45 5 127
Each machine code may be more than one time in the file.
Define a structure named maintenance to manage this data. The members of the structure will be this information.
Define a list of N-type maintenance structures (N = known).
The data in the structure table will be imported by accessing the maintenance.txt serial file. Assume that the value of N exceeds the number of records in the file.
The following are requested (main () function:
1. import the data from the maintenance.txt file into the table of structures by checking the existence of the file (see the code below) according to the above limitation. Find and display the number of lines in the file that the structure table will contain [UNITS 3].
2. Using all the elements in the table of structures to find and display:
a. The number of failures by category of damage.
b. All hours off for one machine if the machine code is entered by the user.
FILE * fp;
if (err = (fopen_s (& fp, filename, mode))! = 0)
printf (\"error reading file .... \\ n\");
else // reading from file