C
Chris Dollin
atif said:It is well known that Pointer just holds address.
No, it isn't. A run-time pointer value /may/ just hold an address,
but it can hold other information as well -- it's not prohibited
by the Standard. A debugging implementation can usefully hold not
only the address, but the permitted range of values of that address,
so that pointer arithmetic can be checked.
But how the machine
came to know that the pointer is holding an address of an Integer so i
will read just 4 bytes and in case of Long 8 bytes.
C pointer variables are typed. The compiler knows at compile-time
what kind of thing the pointer points to, because you tell it.
`int*` variables are supposed to be pointing to `int`s, `char*`
variables to chars, and so on. [Or they may be null pointers,
of course.]