Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a function readBooks that populates a pair of arrays with the titles and authors found in books.txt. This function should: Accept five input

C++image text in transcribed

Write a function readBooks that populates a pair of arrays with the titles and authors found in books.txt. This function should: Accept five input arguments in this order: string fileName: the name of the file to be read. Array of string: titles Array of string: authors int numBookStored: the number of books currently stored in the arrays.You can always assume this is the correct number of actual elements in the arrays. oint size: capacity of the authors/titles arrays. This number should always be greater or equal to the number of books currently stored in the arrays .Use ifstream and getline to read data from the file, placing author names in the authors array and titles in the titles array. You can use the split0 function from Problem 3, with comma() as the delimiter. When you copy your code to the coderunner, make sure you put in the answer box both functions readBooks and split. Special cases to consider: When the file is not opened successfully, return-1 o When numBookStored is equal to the size, return -2. o When numBookStored is smaller than size, keep the existing elements in titles and authors, then read data from file and add the data to the array. The number of books stored in the array cannot exceed to the size of the array. Empty lines should not be added to the arrays

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Describe the rationale behind short-selling.

Answered: 1 week ago

Question

Define the first and second law of thermodynamics?

Answered: 1 week ago