← Back to Streams
Question 611
Event Log
Event Log
Write a functionvoid logEvent(const string& filename, const string& msg)that opens the log file in append mode and adds one line at the end without erasing the lines already there:LOG:followed by a space andmsg, then a newline. The test starts with an empty file, callslogEventthree times with"boot","login"and"exit", then reopens the file and prints every line (see Expected Output). Do NOT write a main function.
Expected Output:
LOG: boot LOG: login LOG: exit LOG: start LOG: stop
= 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.