面试题---反转一个字符串

void reverse(char *str){
    char* end = str;         
    char tmp;
    if (str){
        while (*end != ''){  // 找出字符串的末尾
            ++end;
        }
    }
    end--;       // 回退一个字符
    // 从字符串首尾开始交换两个字符,直至两个指针在中间碰头
    char* p = str;
    while (p < end){
        tmp = *p;
        *p++ = *end;
        *end -- = tmp;
    }
}
原文地址:https://www.cnblogs.com/simplepaul/p/7758054.html