CJCoding With Joseph
15free / daySign inCreate account

Write a function void writeCsv(const string& filename, const vector<string>& names, const vector<int>& scores) that opens filename with an ofstream and writes one line per index i: names[i], a comma (no spaces around it), scores[i], then a newline. The two vectors always have the same length. Do not write a header line.

For names {"Bob", "Amy"} and scores {90, 85} the file must contain exactly: Bob,90 Amy,85

Do NOT write a main function.

Expected output

Bob,90
Amy,85
Zed,100
Eve,72
Max,0

= newline. The output ends with a newline, so print one after the last line.

Hints3 available
Topics
Streamsofstream
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.