CJCoding With Joseph
15free / daySign inCreate account

Split a Record on Pipes

A record holds fields separated by |, for example 9781|The Hobbit|3|12.50. Complete void printFields(const string& record) so it prints every field on its own line, in order, using find to locate each bar and substr to 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
Topics:
Functions
📥 Auto-Input:
9781|The Hobbit|3|12.50\n
This input is automatically fed to your program's stdin
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.