Relative Content

Tag Archive for c++functioninputparameters

Reversing the words inside a sentence in C++

I am trying to write a function that reverses the words inside a string keeping spaces between the words. So, if the input is “abc def ghj” output should be “cba fed jhg”. It works when i put the string by hand into the function ReverseLettersDecode(“abc def ghj) for example. However, when i put the parameter of the function with a input it does not work. Example: ReverseLettersDecode(a) where a is input from the user. I am new to the language so please keep that in mind when explaining 🙂 thanks.