*p++,*++p,*(p++),*(++p)
直接上代码:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main () 5 { 6 int arry[] = {0,1,2,3}; 7 int val = 888; 8 int *p, *tmp; 9 10 p = &arry[0]; 11 val = *p; 12 printf("p->0x%x, val=%d\n", p, val); 13 14 tmp = p; 15 val = *p++; 16 printf("*p++: p->0x%x, val=%d\n", p, val); 17 p = tmp; 18 19 tmp = p; 20 val = *++p; 21 printf("*++p: p->0x%x, val=%d\n", p, val); 22 p = tmp; 23 24 tmp = p; 25 val = *(p++); 26 printf("*\(p++\): p->0x%x, val=%d\n", p, val); 27 p = tmp; 28 29 tmp = p; 30 val = *(++p); 31 printf("*\(++p\): p->0x%x, val=%d\n", p, val); 32 p = tmp; 33 34 return 0; 35 }
输出:
p->0xbf975cd4, val=0 *p++: p->0xbf975cd8, val=0 *++p: p->0xbf975cd8, val=1 *(p++): p->0xbf975cd8, val=0 *(++p): p->0xbf975cd8, val=1
结论: 括号很重要
------------------------------------
Good good study, day day up!
----------------------------------:)