Question
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
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.
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
Return the total number of users in the system, as an integer.
If the file cannot be opened, return -1
Hint: You can use the split() function that was used during recitation
Rating Meaning Did not read Hell No hate it!! Don't like it. Meh neither hot nor cold Liked it! Mind Blown-Loved it! Rating Meaning Did not read Hell No hate it!! Don't like it. Meh neither hot nor cold Liked it! Mind Blown-Loved it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started