代码
/**
* 用指针的方法,将字符串首尾对调输出
* 例如:输入 "ABCD1234efghij"
* 输出:jihgfe4321DCBA
*
*/
#include <stdio.h>
#include <string.h>
#include <dos.h>
int main()
{
char str[] = "ABCD1234efghij";
int length = strlen(str);
char *p1 = str;
char *p2 = str + length - 1;
while(p1 < p2){
char c = *p1;
*p1 = *p2;
*p2 = c;
++p1;
--p2;
}
printf("str is %s\n",str);
return 0;
}