Tag: * P ++ * (p ++) (* P) ++
char ch[3]={‘a‘,‘c‘,‘e‘}; char *p=ch;
1,
printf("%c\n",*p++); printf("%c\n",*p);
Execution result 650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4D/A1/wKioL1RVt9yiIAlTAAAcwxIG2xM519.jpg "Title =" 11_2_1.jpg "alt =" wkiol1rvt9yiialtaaacwxig2xm519.jpg "/>
Note: first, * (pointer operator) and ++ (auto-incrementing operator) both belong to the single-object operator. The priority is the same and the combination is from right to left.
* P ++ executes * P first, that is, extracts the content of the Unit pointed to by P pointer, and then performs auto-increment operations on P, that is, the p Pointer Points to the next unit of the original unit, that is, the pointer P points to the C unit.
2,
printf("%c\n",(*p)++); printf("%c\n",*p);
Execution result:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4D/A1/wKioL1RVvP7BCE3wAAAfYkn_eKo571.jpg "Title =" 11_2_2.jpg "alt =" wkiol1rvvp7bce3waaafykn_eko571.jpg "/>
Note: (* P) ++ we all know that the content of P pointing to the unit is obtained by executing the brackets first. However, unlike * P ++, auto-increment is no longer P, it is the whole * P in the brackets. (at this time, the p pointer does not shift backward, but changes * P, that is, the auto-increment 1 is changed to B)
3,
printf("%c\n",*(p++)); printf("%c\n",*p);
Execution result:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4D/A2/wKiom1RVvJHC1cmKAAAV_LDrGvQ660.jpg "Title =" 11_2_3.jpg "alt =" wkiom1rvvjhc1cmkaaav_ldrgvq660.jpg "/>
Note: * (p ++) executes the P ++ in parentheses first, but if p ++ is still operated (this operation is to take the content that is *, the difference with the first one is that the first one is to get the content of P first, and the output operation is performed before the auto-increment of P, then perform auto-increment on P, so the output in the first sentence is still.
This article is from the "xingnallu" blog, please be sure to keep this source http://781588100.blog.51cto.com/9429625/1570899
About * P ++ (* P) ++ * (p ++)