Capitalize the First Character
mediumQuestion 662Write a function void capitalizeFirst(const string& filename) that opens filename with an fstream in ios::in | ios::out mode, reads its first character with get, moves the write position back to the start with seekp(0), and writes the uppercase version of that character (use toupper from <cctype>) over it with put. Everything else in the file stays exactly as it was. The file always has at least one character.
The test creates the file, calls your function and prints every line of the file. For a file containing hello world it prints the output shown in Expected Output.
Do NOT write a main function.
Expected output
Hello world Zebra crossing second line
= newline. The output ends with a newline, so print one after the last line.
Hints4 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.