I am trying to run the below code in Visual Studio 2008. But at run time the program is throwing an error
Unhandled exception at 0x002e1480 in reverseString.exe: 0xC0000005: Access violation writing location 0x002e573c.
void reverse(char *str)
{
char *end = str;
char tmp;
if (str)
{
while (*end)
{
++end;
}
--end;
while (str < end)
{
tmp = *str;
*str++ = *end; // Error Here
*end-- = tmp;
}
}
}
Thanks in advance for your great help.
stdlibrary.