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3 0 2 5 1 1 4 2 4 5 2 0 2 2 4 1 4 0 2 1 5 3 4 0 2 3 4 3 5 5 5 2 2 4 4 0 2 1 0 3 henry,1 0 3 1 3 2 1 0 2 5 0 5 4 1 1 3 4 4 2 5 1 5 2 2 0 3 3 2 5 2 2 3 3 0 2 1 2 1 3 5 5 5 5 4 3 4 2 4 5 2 brandon,5 3 5 3 3 4 0 1 1 2 0 1 4 4 2 1 4 1 1 2 3 1 0 1 4 0 2 3 2 5 2 5 3 1 0 1 0 4 1 0 2 4 4 4 0 2 2 4 4 2 dorothy,4 5 1 2 0 3 2 2 3 4 3 5 3 3 1 1 0 2 3 5 0 1 1 5 3 5 0 1 1 2 3 0 5 2 2 2 5 3 0 4 2 3 0 0 5 5 0 3 3 2 eric,2 4 5 0 1 3 5 2 0 3 1 4 2 2 0 1 4 1 1 5 2 2 1 2 3 0 1 5 0 1 2 4 4 5 3 0 2 2 4 3 3 1 4 0 4 1 5 3 3 1 raymond,5 5 1 0 0 1 5 2 4 2 2 2 5 3 4 2 0 4 2 5 0 2 3 2 3 4 1 3 2 0 1 5 4 1 0 2 5 1 1 4 5 3 1 4 1 2 3 5 5 0 adam,5 0 2 0 2 1 4 1 3 2 0 3 5 1 4 3 5 1 4 4 2 1 1 4 3 1 4 2 0 5 4 0 2 0 3 1 4 2 5 4 5 2 4 4 3 0 2 3 2 4 johnny,5 1 2 2 2 2 4 3 4 2 1 4 2 3 1 2 0 2 2 5 4 0 3 1 0 0 1 1 0 2 2 1 5 1 1 4 5 2 4 3 5 5 3 4 1 3 2 2 0 5
split function:
int split (string str, char c, string array[], int size) { if (str.length() == 0) { return 0; } string word = ""; int count = 0; str = str + c; for (int i = 0; i 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 Did not read Hell No - hate it! Don't like it. Meh neither hot nor cold Liked it! Mind Blown Loved it! Your function should . Accept six arguments in this order: o string: the name of the file to be read o string array: usernames o 2D int array: list of ratings for each user (first index specifies user) o int: number of users currently stored in the arrays o int: row capacity of the 2D array (convention: array[row][column) lassume to be 100] o int: column capacity of the 2D array fassume 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
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