用指针的方法,将字符串“ABCD1234efgh”前后对调显示//不要用strlen求字符串长度,这样就没分了

#include<stdio.h>

int main(int argc, const char *argv[])
{
    char str123[]="ABCD1234efgh";
    char *p1  = str123;
    char *p2 = str123 ;

    while(*++p2);
    p2 -= 1;
#if 0
    while(*p2++) ;
    p2 -= 2 ;
#endif
    while(p1 < p2)
    {
        char c  = *p1;
        *p1  = *p2;
        *p2  = c;
        p1 ++;
        p2 --;
    }

    puts(str123);
    return 0;
}
原文地址:https://www.cnblogs.com/smile-at-you/p/3362181.html