Home>Article>Backend Development> What does c language *p++ mean?
[*p] means to first take out the data in the address unit pointed to by the pointer p, and then add 1 to the value. Since the priority of the operator [*] is higher than that of the operator [ ], it is First, take the data in the address unit pointed by pointer p, and then the data in the next location pointed to by p.
*p
means to first take out the data in the address unit pointed to by the pointer p, and then add 1 to the value. Due to the operation The priority of the symbol * is higher than that of the operator, so the data in the address unit pointed by the pointer p is first fetched, and then, p points to the data in the next location. [Recommended tutorial:C Tutorial]
Since the operator * has a higher priority than the operator , the data in the address unit pointed to by the pointer p is taken first. The details are as follows:
1. Get the value of the current position of the array *p;
2. Then, p points to the data at the next position.
The code running diagram is as follows:
*p: * and are both operators of the same level, right associative. However, the entire expression must be calculated before it is calculated. First, extract the value of the object pointed to by P, and then perform the calculation on P to point to the next object.
*(P): This () is a bit confusing. It needs to be added after the entire expression is calculated. So the same as above, the object value pointed to by P is still extracted. After extraction, P points to the next object. .
(*p): This is different. They get the value first and then the value;
*p: They get the value first and then the value;
Why do some add values and some add addresses? This is the role of brackets, which bind them as a whole. Also look at the combination.
The above is the detailed content of What does c language *p++ mean?. For more information, please follow other related articles on the PHP Chinese website!