Question: C++ Write a function readRatings that performs a similar task on the user ratings file. Each username represented in ratings.txt is followed by list of
C++ Write a function readRatings that performs a similar task on the user ratings file. Each username represented in ratings.txt is followed by list of integers--ratings of each book in books.txt. Rating Meaning 0 Did not read 1 Hell No - hate it!! 2 Dont like it. 3 Meh - neither hot nor cold 4 Liked it! 5 Mind Blown - Loved it! Your function should: Accept six arguments in this order: string: the name of the file to be read string array: usernames 2D int array: list of ratings for each user (first index specifies user) int : number of users currently stored in the arrays int: row capacity of the 2D array (convention: array[row][column]) [assume to be 100] int: column capacity of the 2D array [assume to be 50] Use ifstream, stringstream, and getline to read and parse data from the file, placing usernames in the usernames array and book ratings in the ratings array (stoi will also be useful here) Print the username of each user as they are added to the system cout << username << "..." << endl; Return the total number of users in the system, as an integer. If the file cannot be opened, return -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
