alphabetize program

closed account (j1AR92yv)
How do I write a program where the user can input strings, and the program will alphabetize it?
Like say the program asked for the first string, and the user inputs like "egg" or something. Then, the program asks for a second string, "rock". Then, a third string, "book".
After all the strings are inputted it, how does one make a program that alphabetizes the strings. So, the output becomes

book
egg
rock

I know it involves using cin three times, and then vectors.
Hello staamatis,

If you used a while or for loop for input you would only need one "cin" statement. I am also thinking of a function to make sure all letters are lower or upper case before you use "std::sort(...)" on the vector.

Put together some code and we can see what happens. That way you can get some guidance on what to do and what you can use.

Remember that when looping for input you will need some way out of the loop.

Hope that helps,

Andy
Topic archived. No new replies allowed.