← Back to Streams
Question 603
Write Then Read Back
Write Then Read Back
The program opens the filewords.txtwith anofstreamcalledout, closes it, then reopens the same file with anifstreamand prints every line it finds. The reading part is already written. Fill in the two commented lines so the file contains exactly two lines:alphaon the first line andbetaon the second (each followed by a newline). Expected output the output shown in Expected Output.
Expected Output:
alpha beta
= newline. The output ends with a newline — print one after the last line.
Hints2 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.