CJCoding With Joseph
15free / daySign inCreate account

Reset a File with ios::trunc

Write a function void resetFile(const string& filename) that opens filename with an fstream in ios::out | ios::trunc mode and writes the single line reset (followed by a newline) to it.

The test fills the file with several old lines first, calls your function, then prints every line of the file (see Expected Output).

Do NOT write a main function.

Expected Output:

reset
reset

= newline. The output ends with a newline — print one after the last line.

Hints2 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.