← Back to Functions
Question 721
Split a Record on Pipes
Split a Record on Pipes
A record holds fields separated by|, for example9781|The Hobbit|3|12.50. Completevoid printFields(const string& record)so it prints every field on its own line, in order, usingfindto locate each bar andsubstrto copy the text between them. A field may be empty (two bars in a row print an empty line), and a record with no bar at all is a single field. The hidden driver reads one line and passes it to your function. Do NOT write a main function.
Expected Output:
9781 The Hobbit 3 12.50
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Functions
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.