1 //指针的运算
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 void print_reverse(char *s)
6 {
7 size_t len = strlen(s);
8 char * t = s + len - 1;
9 printf("逆序之后的字符串为:");
10 while(*t >= *s){
11 printf("%c",*t);
12 t = t - 1;
13 }
14 printf("\n");
15 }
16 int main()
17 {
18 char a[] = {"abcdefg"};
19 printf("原始的字符串:%s\n",a);
20
21 print_reverse(a);
22 return 0;
23 }
so@ubuntu:~/linuxc/exec$ a.out原始的字符串:abcdefg
逆序之后的字符串为:gfedcba