logo CodeStepByStep logo

reverseWordOrder

Language/Type: C++ string return
Related Links:

Write a function named reverseWordOrder that accepts a string s as its parameter and returns a new string with the words from s in reverse order. A word is a sequence of one or more non-space characters; words are separated by single spaces. For example, the call of reverseWordOrder("Hello what is your name?") should return "name? your is what Hello".

This problem is fairly straightforward to solve if you use the stringSplit function. For added challenge, can you solve it without using stringSplit?

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.