Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What does *p=a mean in C language?
What does *p=a mean in C language?
Say * and & first; In order to understand, you can think that * here is the content,&; Is to get the address.

I won't discuss their differences, because * p = &;; Form A is generally wrong, and commonly used is P = &;; Answer.

Compare *p=a and p = &;; Answer. Look at the picture. The picture is very detailed.

Obviously they are equivalent.

Then compare * p = &;; A and p = &;; a;

Then both are assignments to pointer variables, and there are two forms of assignment.

① Define first, then assign value.

int a=3,* p; (define pointer variable *p)

p = & ampa; (address pointer variable)

② Assign values when defining variables.

int a=3,* p = & ampa

That is to say, when assigning a value,

int * p = & ampa

be qualified for sth

int *p,

P =&a?

The difference between them is actually

Int * p = & ampA is to define *p at the same time and assign P (that is, the address of A is assigned to P), and P =&; A, only assign values to p, and do not define pointer variables.

However, it should be noted that "* p = &;; "A" is the correct writing.

Don't use * p =&in other cases; A, this form, because it is not right at all, as shown below. I've always wondered why * p = &;; A is there anything wrong? Later, the teacher explained that this form was only established under the above circumstances, and other situations were really wrong.