sorting of string

can you help me have this code a variable/subject to change. you're the one who will input a string and output the sorted word like..
Enter some string:
one
two
three

Ouput:
three
two
one
Last edited on
You want to sort the string by the value of the word? That's not an easy thing todo.
yes... how can i do that .. that code is running but it only display the first word.. for example i input the word : one two three and then it would only output the word "one"

but if I changed this char buf[50]; to char buf[50]= one two three
it would output the correct answer "three two one"
if you want to get the whole string line input its going to be better to use

 
getline(cin, buf);


rather than

 
cin >> buf;


change

 
char buf


to

 
string buf;
Last edited on
Topic archived. No new replies allowed.