Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language: (text files provided) Description: This function should open and read the given input file which contains information about all rental cars. It

In C language: (text files provided)

Description: This function should open and read the given input file which contains information about all rental cars. It should store each car's data in an element of the given array arr, and return the number of cars it read from the file. Notice that the file contains extra information which you should just skip/ignore (using * option in fscanf) Obviously the value of member is_available should be initialized to 1 for all elements of array arr.

Function:

int readCarsInfo(char *filename, CarInfo arr[]) { int n = 0;

// ...

return n; }

Seperate text file, cars.txt:

image text in transcribed

Car ID Car Make Car Model Year Unit Price Per Day MPG ---------------------------------------------------------------------------------------------------------------------------------------------------------- 311 Chevrolet Chevelle-Malibu 1 2014 45.99 21 312 Buick Skylark-320 2014 79.95 19 313 Plymouth Satellite 2017 61.75 N/A 314 AMC Rebel-SST 2016 99.99 16 315 Ford Torino 2015 85.99 22.1 316 Ford Galaxie-500 2016 61.95 29.5 317 Chevrolet Impala 2013 42.99 18.7 318 Plymouth Fury-iii 2017 69.85 20.52 319 Pontiac Catalina 2012 29.99 N/A 320 AMC Ambassador-DPL 2015 95.99 16.30 321 Citroen DS-21-Pallas 2016 59.75 19.05

In a seperate struct.h:

typedef struct { unsigned int ID; //unique identification number of the car char model[20]; char make[20]; unsigned int year; float unit_price; //rental cost per day for this car int is_available; //whether the car is already rented or not (0 if it's rented, 1 otherwise) } CarInfo;

Car ID 311 312 313 314 315 316 317 318 319 320 321 Car Make Chevrolet Buick Plymouth Ford Ford Chevrolet Plymouth Pontiac AMC Citroen Car Model Chevelle-Malibu 1 Skylark-320 Satellite Rebel-SST Torino Galaxie-500 Impala Fury-iii Catalina Ambassador-DPL DS-21-Pallas Year 2014 2014 2017 2016 2015 2016 2013 2017 2012 2015 2016 Unit Price Per Day 45.99 79.95 61.75 99.99 85.99 61.95 42.99 69.85 29.99 95.99 59.75 MPG 21 19 N/A 22.1 29.5 18.7 20.52 N/A 16.30 19.05

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions