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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.5: A Case Study: Pollen Count File Update
Problem 4E
icon
Related questions
Question

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

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Hello,

I get the following error when trying to run this code;

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

 

ssages:
Build x
==[ Build | carModels | Debug ]=====
:=
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/michaelelliotcunningham/CLionProjects/carModels/cmake-build-debug --target carModels
[1/2] Building C object CMakeFiles/carModels.dir/main.c.o
/Users/michaelelliotcunningham/CLionProjects/carModels/main.c:30:71: warning: format specifies type 'int *' but the argument has type 'unsigned int' [-Wformat]
fscanf (fptr1, "%s%s%d", arr1[i].longName, arr1[i].shortName, arr1[i].numEmployees);
ANNNN ~ N~~NNNNNN
/Users/michaelelliotcunningham/CLionProjects/carModels/main.c:34:51: warning: format specifies type 'int *' but the argument has type 'unsigned int' [-Wformat]
fscanf (fptr2, "%s%d", arr2[i].modelName, arr2[i].numEmployees);
ANNNN NNNNN NNNNN NNNNN
2 warnings generated.
[2/2] Linking C executable carModels
Build finished
Transcribed Image Text:ssages: Build x ==[ Build | carModels | Debug ]===== := /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/michaelelliotcunningham/CLionProjects/carModels/cmake-build-debug --target carModels [1/2] Building C object CMakeFiles/carModels.dir/main.c.o /Users/michaelelliotcunningham/CLionProjects/carModels/main.c:30:71: warning: format specifies type 'int *' but the argument has type 'unsigned int' [-Wformat] fscanf (fptr1, "%s%s%d", arr1[i].longName, arr1[i].shortName, arr1[i].numEmployees); ANNNN ~ N~~NNNNNN /Users/michaelelliotcunningham/CLionProjects/carModels/main.c:34:51: warning: format specifies type 'int *' but the argument has type 'unsigned int' [-Wformat] fscanf (fptr2, "%s%d", arr2[i].modelName, arr2[i].numEmployees); ANNNN NNNNN NNNNN NNNNN 2 warnings generated. [2/2] Linking C executable carModels Build finished
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,