swap string a in place to string b in C++ : <p>swap string a in reverse to b.
swap string a in place to string b in C++</p>

<p>// 1e9+5</p>

<pre><code>#include &lt;iostream&gt; 
#include &lt;string&gt;
using namespace std; 


int main ()
{
    string a="Hello,Sir";
    string b="";

    int k=5;
    int last=k; 
    for (int i=0;i&lt;k;i++)
    b[i]=a[last--];

    cout &lt;&lt; b;

    return 0; 
}
</code></pre>
