Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Description:
- Include the following definitions at the top of your program:
- #define MAX_STRING_LEN 20
- typedef struct {
- int year;
- char* make;
- char* model;
- int miles;
- } Car;
- void fill_garage(Car** garage, char* cars, int* size);
- Parameter: garage – A pointer to the pointer, which points to the head of an array of cars
- Parameter: cars – The name of the input file
- Parameter: size – A pointer to the variable where the size of the array will be stored
- This function will dynamically create an array to hold the cars and read the contents of
- the input file into it. This is the only function which is allowed to use malloc in your
- assignment.
- int equals (Car* car, int year, char* make, char* model);
- Parameter: car – A pointer to a car struct
- Parameter: year – A valid year
- Parameter: make - A cars make
- Parameter: model – A cars model
- Return: 1 if the car has the given year, make, and model; 0 otherwise
- This function will determine if the provided car has the specified year, make, and model
- void drive_cars(Car* garage, int* num_cars, char* driving_records);
- Parameter: garage – An array of cars
- Parameter: num_cars – The length of the garage array
- Parameter: driving_records – The name of a file containing driving records
- This function will read from the file specified by the driving_records parameter and on
- each line read in a year, make, model, and number of miles driven. It will then add the
- number of miles to the specified car. If the car does not exist, no action should be taken.
- void store_car_statisitcs(Car* garage, int num_cars, char* outFile);
- Parameter: garage– An array of cars
- Parameter: num_cars – The length of the garage array
- Parameter: outFile – The name of the file to store the car information
- Write the car statistics to the output file. See example output below.
- void empty_garage(Car* garage, int num_cars);
- Parameter: garage – An array of cars
- Parameter: num_cars – The length of the garage array
- Frees all malloced memory
- int main(int argc, char* argv[]);
- Main should take in the names of the three files as command line arguments and then act
- as a driver to call the other functions. It should error check for the correct number of
- command line arguments.
- input file
- 3
- 1993 Chevy Blazer 100200
- 2007 Honda Civic 23787
- 1903 Ford ModelT 90000
- update file
- 4
- 1993 Chevy Blazer 39
- 1903 Ford ModelT 20
- 1993 Chevy Blazer 2
- 2014 Jeep Patriot 100
- correct output
- The 1993 Chevy Blazer drove 100241 miles
- The 2007 Honda Civic drove 23787 miles
- The 1903 Ford ModelT drove 90020 miles
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement