What does c language *p++ mean?

云罗郡主
Release: 2020-09-14 11:47:28
Original
75308 people have browsed it

[*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.

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. 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:

What does c language *p++ mean?

*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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template