标签:
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, *p = a;
printf("------------右++-----------\n");
printf("*p =%d\n", *p);
printf("指针p地址:%d\n", p);
printf("*p++ = %d\n", *p++);
printf("指针p地址:%d\n", p);
printf("(*p)++ = %d\n", (*p)++);
printf("指针p地址:%d\n", p);
printf("*(p++) = %d\n", *(p++));
printf("指针p地址:%d\n", p);
printf("------------左++----------\n");
printf("*p =%d\n", *p);
printf("指针p地址:%d\n", p);
printf("*++p = %d\n", *++p);
printf("指针p地址:%d\n", p);
printf("(*++p) = %d\n", (*++p));
printf("指针p地址:%d\n", p);
printf("*(++p) = %d\n", *(++p));
printf("指针p地址:%d\n", p);

综上所述:
*p++是先取出*p的值,然后让p++
(*p)++是先取出*p的值,让这个值++
*(P++)是先取出*p的值,让p++
所以,*p++等价于*(P++)
而且printf的运行顺序是从右向左运行。而且右++是在整个运算表达式运算完才进行,而且右++的执行顺序是从左到右进行。而左++遇到变量就会立即增加变量的值。
标签:
原文地址:http://www.cnblogs.com/cnfanhua/p/4231085.html