Longest Line
mediumQuestion 589Write a function string longestLine(const string& filename) that returns the line of the file with the most characters. If several lines tie for the longest, return the one that appears first in the file. For a file containing:
kiwi strawberry fig
the function returns strawberry.
The test prints the returned line on its own line, for example (see Expected Output).
Do NOT write a main function.
Expected output
strawberry apple
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Streamsifstream
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.