ip
the memory address of the variable
num
. This address is the location of the
variable in the computer’s internal memory. It has
nothing
to do with the
value
of
num
.
Thus,
ip
does not
contain the value 10 (
num
’s initial value). It contains the address at which
num
is stored. The operation of
&
can be remembered as returning “the address of” the
variable it precedes. Therefore, the preceding assignment statement could be verbalized
as “
ip
receives the address of
num
.”
The second operator is
*
, and it is the complement of
&
. It is a unary operator that
evaluates to the value of the variable located at the address specified by its operand. That
is, it refers to the value of the variable pointed to by a pointer. Continuing with the same
example, if
ip
contains the memory address of the variable
num
, then
int val = *ip;
will place into
Do'stlaringiz bilan baham: |