Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the code program below to make the data in your program persistent by storing all car and rental records into separate files and using

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Use the code program below to make the data in your program persistent by storing all car and rental records into separate files and using the information when the program starts up. The program must implement four new functions void write Rentals(char filename, Rental allRentals, int totalRentals); int readRentals(char filename, Rental allRentals); void writeCars(char filename, Car *allCars, int totalCars); int readCars(char filename, Car "allCars) Use the command line arguments to read two text strings from the command line when the program is started. The first string must specify the file name of the rental records file, the second string specifies the file name of the car records file. The program must call the two read functions. Note, the previous call of createlnventory() in main() is no longer needed as the car inventory is read from a file Before the program terminates, it must store the rental and car records using the corresponding functions For implementing the functions, you must use text-based file I0. When you create the file to write rental or car records to the file, begin by writing the entire record on a single line with eaclh field separated by one space using fprintf), then continue with the next record the same way u all records have been written to the file. You should have as many text lines as records. For example, the format for the 3 cars specified in the project description of project 4 should look asfollows 1234 VW Golf 2 66.00 2241 Ford Focus 4 45.00 3445 BMW X3 4 128.00 You may assume that none of the text strings for make or model contains spaces in their names (so %s in fscanf will work). For reading the records, do the same but use fscanf() to read numbers or strings for the individual fields of records. Assume that each record is completely stored in the file. If you reach the end of a file, then you should have a complete count of records that have been successfully read. Return that number as the number of rentals or cars. Your program must be robust to handle empty text files or missing files

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions