c++: I am trying to reverse the order of words in string (not the whole string)
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;

void RevStr (char *str)
{   
    if(*str !=0)
    {
        vector&lt;char&gt; v1;

        while((*str != ' ')&amp;&amp;(*str !=0))
            v1.push_back(*str++);
        // trying to not add space in the last word of string
        if(*str !=0)
        {
            v1.push_back(' ');
            str++;
        }
        RevStr(str);
        cout&lt;&lt;*str;
    }


}
int main()
{
    RevStr("hello world!");
    cout&lt;&lt;endl;

}
</code></pre>

<p>I want to change the order of words in the string  for example " how are you" => "you are how"</p>

<p>I am having some problem, its not printing correctly (print only w), please help me and tell me what i did wrong. However i know that I should not call "cout&lt;&lt;*str;
" since i am inserting the "array of char" in stack (recurssion) but i dont know what i need to do.</p>
