**&ptr
&
and *
are unary operators which have an opposite meaning 1 from the other.
&(lvalue)
means to return the address of the corresponding lvalue
while *(lvalue)
means to return the value from the address pointed by lvalue, considering the type of lvalue, in order to know how to dereference it.
Visually the meaning of these operators looks like this (my talent in artist-mode
of emacs
is not too big):
+----------------+
| ptr = *&ptr |
+--------------+-+
/ \
/ \
&ptr \
+----------------+
| *ptr |
+----------------+
/
/
ptr
Note that I marked inside the box the right value, while outside the box the addresses of memory of the left values of the corresponding memory locations.
Now when you write *&(lvalue)
, it means to get the value from the address of lvalue, which is written shortly lvalue
.
So **&ptr
means *ptr
-- namely the value from the adress pointer by ptr, dereferenced as integer, in your case 10.
2**ptr
The lexer will split the code in tokens and the parser will build a tree like that:
(2) * (*ptr)
In this case the result will be 2 times the value from the adress of ptr
, in your case 20
.