void addNewCar CompanyT company Can somebody explain this

void addNewCar ( CompanyT *company )

Can somebody explain this function call? How is the function calling the structure with a pointer?

How would I accomplish this within the body of my function?

void addNewCar (CompanyT *company); This function must prompt the user for the fields to initialize the values in the structure composing a car. It must use the value of totalCars to select the array location in allCars and set the corresponding fields of the CarT structure. The function must check that no more than 20 cars are stored in the array. If an attempt is made to add more than 20 cars to the array allCars, the function must print an error message and return.

Here is the structure companyT:

typedef struct {
   CarT allCars[20];
   RentalT allRentals[20];
   ReservT allReserv[60];
   int totalCars;
   int totalRentals
   int totalReserv
  
} CompanyT;

Solution

This function call means the refrence to a structure variable is passed to this method. The call to this function in main will look like:

CompanyT comp1;

addNewCar(&comp1);

Now what you will do in this method, you will get input from user for the values of this structure and if value of total cars is given as greater than 20 give error otherwise get values for a CarT structure.

void addNewCar ( CompanyT *company ) Can somebody explain this function call? How is the function calling the structure with a pointer? How would I accomplish t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site