Question: 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++
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
Get step-by-step solutions from verified subject matter experts
