When you create a pointer you use
int *pA;
Afterwards, using *pA
means you're accessing the value pointed to by the pointer.
When you use &a
you are using the Address-of Operator which returns the address of the memory location in which the data stored of the variable a
(which is a integer) is stored.
So, the correct assignment is pA = &a
since you're copying the address of a
to pA
which is supposed to hold addresses of memory locations.
But *pA
represents the value in that memory location (an integer) so it is incorrect to assign an address to *pA
- this is why the right syntax is pA = &a
.