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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education