No, the two are fundamentally different. The expression &number
evaluates to the address at which the value of number
is stored, whereas the expression number
evaluates directly to the value itself.
Suppose that the value of number is 42, and that it is stored att adress 1024 in memory. Memory is linear*, so it will look something like this:
+--------+ Address 0
| ...... |
+--------+
| 42 | Address 1024 (value is stored here)
+--------+
| ...... |
+--------+ Address xxxx
Now, the statement tommy = &number;
will assign the value 1024 to tommy
, since &number == 1024
, the address of number
.
The other statement, provided it compiles at all, will assign the (nonsensical) value 42 (the value of number
) to tommy
. Any attempts to dereference (access the data pointed to by) tommy
are likely to generate a segmentation fault, because 42 is (probably) not a valid address.
*At least, the operating system will give you the illusion that your address space is linear and contiguous.