1 int main(int argc, char* argv[])
2 {
3 char* str[] = {"Welcome", "to", "Fortemedia", "Nanjing"};
4 char** ptr = str + 1;
5 printf("ptr = %s\n", *ptr);
6 puts("1------------------------------");
7
8 str[0] = (*ptr++) + 2;//*ptr 取str+1所指的指针,*ptr + 2 指向了“to”后面的'\0'。
9 printf("ptr = %s\n", *ptr);
10 printf("str = [%s]\n", str[0]);//[]
11 puts("2------------------------------");
12
13 str[1] = *(ptr + 1);
14 printf("ptr = %s\n", *ptr);
15 printf("str = [%s]\n", str[1]);//[Nangjing]
16 puts("3------------------------------");
17
18 str[2] = ptr[1] + 3;
19 printf("ptr = %s\n", *ptr);
20 printf("str = [%s]\n", str[2]);//[jing]
21 puts("4------------------------------");
22
23 int x = (str[2] - str[1]);printf("x = %d\n", x);
24 str[3] = ptr[0] + x;
25 printf("str = [%s]\n", str[3]);//[g]
26 printf("ptr[0] = %s\n", ptr[0]);
27 puts("5------------------------------");
28
29 getchar();
30 return 0;
31 }