Search:
Forum
General C++ Programming
Need aid on c++ program!
Need aid on c++ program!
Jan 23, 2011 at 4:04am UTC
tarbeux
(22)
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!
Jan 23, 2011 at 5:21am UTC
wolfgang
(381)
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
Jan 23, 2011 at 5:33am UTC
rocketboy9000
(562)
You can eliminate the vector.
Jan 23, 2011 at 6:09am UTC
ultifinitus
(1446)
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.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs