← Back to Streams
Question 614
Write CSV
Write CSV
Write a functionvoid writeCsv(const string& filename, const vector<string>& names, const vector<int>& scores)that opensfilenamewith anofstreamand 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 — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
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.