CJCoding With Joseph
15free / daySign inCreate account

Write, Seek, Read

The program below opens note.txt with an fstream in ios::in | ios::out | ios::trunc mode. Complete it so that it:
1. writes the word hello to the file,
2. moves the read position back to the start of the file with f.seekg(0),
3. reads one word from the file into word with >>.

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
Topics:
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.