← Back to Streams
Question 588
Parse Name,Score Lines
Parse Name,Score Lines
A file holds one record per line in the formname,scorewith no spaces around the comma: Bob,90 Amy,85 Write a functionvoid printScores(const string& filename)that prints one line per record in the form<name> scored <score>, in file order, each ending with a newline (see Expected Output). The score is printed exactly as it appears in the file. Do NOT write a main function.
Expected Output:
Bob scored 90 Amy scored 85 Li scored 7 Mo scored 42 Na scored 99
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Streamsifstream
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.