我正在尝试在 Visual Studio 2008 中运行以下代码。但在运行时程序抛出错误
reverseString.exe 中 0x002e1480 处未处理的异常:0xC0000005:访问冲突写入位置 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;
      }
   }
}
提前感谢您的大力帮助。