Need aid on c++ program!

The task is to make a program that reads a list of strings until the word "end" appears, and returns the longest string (word) that was entered.

Ex:

Hi
everyone
good
morning
The longest string is: everyone

I am having great difficulty with this. Thanks in advance!
Have you actually tried writing this yourself?

Seems simple:
* use fstream to read a file in.
* read it with a loop into a temp variable
* if the temp var != end store it in a vector of strings
* when you hit end compare each strings length in the vector searching for the highest.
* print it out
You can eliminate the vector.
Indeed, no need- just store the longest string as you find it, as you read through the file swap it out if you find a bigger one.
Topic archived. No new replies allowed.