Number Each Line
mediumQuestion 585Write a function void printNumbered(const string& filename) that prints every line of the file preceded by its 1-based line number, a colon and one space. For a file containing:
milk eggs
the function prints exactly the output shown in Expected Output.
Each output line ends with a newline.
Do NOT write a main function.
Expected output
1: milk 2: eggs 1: open door 2: walk in 3: sit down
= newline. The output ends with a newline, so 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.