用C++实现void reverse(char* str)函数,即反转一个null结尾的字符串.

void reverse(char* str)
{
    char *end = str, *begin=str;
    char temp;
    while(*end!='\0')
    {
        end++;
    }
    end--;
    while(begin<=end)
    {
        temp = *end;
        *end-- = *begin;
        *begin++ = temp;
    }
}

 

posted @ 2014-05-16 00:02  CrazyCode.  阅读(523)  评论(0编辑  收藏  举报