CJCoding With Joseph
15free / daySign inCreate account

Write One Line

Write a function void writeGreeting(const string& filename) that opens filename with an ofstream (the starter does this as out) and writes exactly one line: Hello, file! followed by a newline. Nothing else may be written.

The test calls your function, then reopens the file and prints every line, so the output is exactly what is shown in Expected Output.

Do NOT write a main function.

Expected Output:

Hello, file!
Hello, file!

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

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