← Back to Streams
Question 650
Write, Seek, Read
Write, Seek, Read
The program below opensnote.txtwith anfstreaminios::in | ios::out | ios::truncmode. Complete it so that it: 1. writes the wordhelloto the file, 2. moves the read position back to the start of the file withf.seekg(0), 3. reads one word from the file intowordwith>>. The last line, already written, prints the word. The program must print exactly the output shown in Expected Output.
Expected Output:
hello= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Streamsfstream
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.