I'm learning C and C#. I'm learning about pointers and don't know what it means to combine the indirection operator and the address operator. What does it mean to combine the two?
Here is an example:
int *p, *q;
p = *&q;
&
can be thought of as an address of (<something>)
operator. So &q
is address of q. Now *
can be thought of as an value at (<something>)
operator. So *q is basically the value stored at the address contained in q, i.e, *
treats the variable as always containing an address. Now *&q, by associativity is *(&q). Which means
value stored at (address of q)
which is same as value stored at q
address of q will be having another address since q is a pointer. So it is the same as
p=q