← Back to Streams
Question 648
Append with fstream
Append with fstream
Write a functionvoid appendFs(const string& filename, const string& line)that opensfilenamewith anfstreaminios::out | ios::appmode and writeslinefollowed by a newline. The test writes the linestartinto the file first, callsappendFs("journal_a.txt", "more"), and then prints every line of the file (see Expected Output). Do NOT write a main function.
Expected Output:
start more x y
= newline. The output ends with a newline — print one after the last line.
Hints2 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.