C语言 字符串倒序输出

#include 
#include 

void reverse(char* s)
{
    char *p,*q,temp;
    p = s;
    q = s + strlen(s) - 1;
    while(p < q)
    {
        temp = *p;
        *p = *q;
        *q = temp;
        p++;
        q--;
    }
}

int main()
{
    char name[] = "abcdef";
    reverse(name);
    printf("%s\n",name);

    return 0;
}

  

你可能感兴趣的:(C语言 字符串倒序输出)