Written in C, Please provide comments to the code. Using the two structures below, write a C Program which can fill and initialise the structures like this with data read from the attached files: manufacturers.txt and models.txt. For each of the 5 records in the models.txt file, the program should print: The model name The number of employees involved in the model’s production The manufacturer’s longName, The manufacturer’s shortName The total number of employees in the manufacturer’s company Sample output PASSAT, 100, VOLKSWAGEN, VW, 2000 Notes Arrays should be used to hold the collection of structs. One array for the model structs and one array for the manufacturer structs. You can use strcmp() function to compare two strings (e.g. the manufacturer names). struct manufacturer{ char longName[11]; char shortName[3]; unsigned int numEmployees; // total number of employees in the company }; struct model{ char modelName[11]; unsigned int numEmployees; //number of employees involved in the model’s production struct manufacturer aManufacturer; }; two files are ---------------------------- models2.txt FOCUS 100 FORD KA 200 FORD CEED 400 KIA PASSAT 100 VOLKSWAGEN SPORTAGE 200 KIA ---------------------------------------------------- manufactures.txt VOLKSWAGEN VW 10000 FORD FD 30000 SEAT ST 12000 KIA KA 15000
Written in C, Please provide comments to the code.
Using the two structures below, write a C Program which can fill and initialise the structures like this with data read from the attached files: manufacturers.txt and models.txt.
For each of the 5 records in the models.txt file, the program should print:
The model name
The number of employees involved in the model’s production
The manufacturer’s longName,
The manufacturer’s shortName
The total number of employees in the manufacturer’s company
Sample output PASSAT, 100, VOLKSWAGEN, VW, 2000
Notes
Arrays should be used to hold the collection of structs. One array for the model structs and one array for the manufacturer structs. You can use strcmp() function to compare two strings (e.g. the manufacturer names).
struct manufacturer{
char longName[11];
char shortName[3];
unsigned int numEmployees; // total number of employees in the company
};
struct model{
char modelName[11];
unsigned int numEmployees; //number of employees involved in the model’s production
struct manufacturer aManufacturer;
};
two files are
----------------------------
models2.txt
FOCUS 100 FORD
KA 200 FORD
CEED 400 KIA
PASSAT 100 VOLKSWAGEN
SPORTAGE 200 KIA
----------------------------------------------------
manufactures.txt
VOLKSWAGEN VW 10000
FORD FD 30000
SEAT ST 12000
KIA KA 15000
Step by step
Solved in 2 steps
Hello,
I get the following error when trying to run this code;
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)