reversing of a string
<pre><code>#include&lt;iostream&gt;
#include&lt;string.h&gt;
using namespace std;
char * reverse (char *);
int main()
{
    char * a;
    cout&lt;&lt;"enter string"&lt;&lt;endl;
    gets(a);
    cout&lt;&lt;a;
    cout&lt;&lt;"the reverse of string is"&lt;&lt;reverse(a);
    return 0;
}
char * reverse (char * b)
{
    int i,j=strlen(b);
    for(i=0;b[i]!='\0';i++)
    {
        char temp;
        temp=b[j-i-1];
        b[j-i-1]=b[i];
        b[i]=temp;
    }
    return b;
}
</code></pre>

<p>This program is giving no compile time error.But it does give run time error and does not give desired output. Please explain the cause.As I am not that much good in C++ so please forgive me if my question is not upto mark.</p>
