However, as we'll see today, there need be no fear or confusion regarding pointers. Conceptually, they are actually quite simple, and if we can keep focused on the important principles, we'll be able to use them effectively.
A pointer is best thought of as the memory address of the thing to which it points, and, in most implementations, it is.When we discussed the general organization of a computer and of memory in particular, we noted that memory is divided into words each of which has an address. It's that address that a pointer holds. A pointer is just like any other variable in that it has a value, but a pointer's value tells us where some information is as opposed to what some information is.
Suppose we have a pointer,
, to a character, and let's say that
the character it points to is the character
Then we have a situation as shown in this figure.
Here both the pointer and the character are stored in memory, but
it so happens that the number stored in the memory location we've called
is the memory address of the character to which
Usually, we don't worry about keeping track of the actual memory addresses as we program. The compiler does that for us. Instead, we generally draw pointers and the things they point to by using arrows as shown in this figure.