- #include <stdio.h>
- #include <string.h>
- void reverse(char *p) {
- char c, *p1, *p2;
- for (p1=p, p2=p+strlen(p)-1; p1<p2; c=*p1, *p1=*p2, *p2=c, p1++, p2--);
- }
- /**test**/
- int main() {
- char p[4] = {'a','b','c','\\0'};
- reverse(p);
- puts(p);
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/1203201511878.html
来源: http://www.codesnippet.cn/detail/1203201511878.html