strings

I have been given an assignment to write a program that will allow the user to input infinite amount of last names, but when the user presses "1" the program will sort last names alphabetically.

So guys if you can please help. I would really appreciate you giving me the code and explaining what you have done. It will help me understand loops and strings better.

I know that you have to make a string for first name and for last name and later you have to use loops and if statements for your last name string(this came from my head ;D).

Anyways, thanks in advance :D
It will help me understand loops and strings better.
No, it won't. Do your own homework.
Can you provide the assignment, word for word?
Well actually this is not my homework :D If you read my previous post I give myself tasks which will improve my performance in c++ . So I've got an idea about this and well I can't seem to do it...

Slurpee umm what didnt you understand ? :D
I would use std::vector to store the names and std::sort to sort them
Look like all you need to do is create a vector of structs. Each struct contains a string for the last name, and a string for the first name. Then, use std::sort() to sort the vector use the last name as the parameter.

OR you could make a class, and have two variables, one for each of the names, then use std::sort() to sort a vector of the objects of "Names" which you created yourself. The first way is easier.
Last edited on
More info please, I will look into what you said Peter and Slurpee

EDIT : So what you're saying is that I have to learn vectors... hmm okay :D
Last edited on
Topic archived. No new replies allowed.