Chapter 13. Simple Pointers
The choice of a point of view is the initial act of culture.
There are things and pointers to things. Knowing the difference between the two is very important. This concept is illustrated in Figure 13-1.
In this book, we use a box to represent a thing. The name of the
variable is written on the bottom of the box. In this case, our variable
thing. The value of the
variable is 6.
The address of
0x1000. Addresses are automatically
assigned by the C compiler to every variable. Normally, you don’t have
to worry about the addresses of variables, but you should understand
that they’re there.
Our pointer (
to the variable
thing. Pointers are
also called address variables because they contain
the addresses of other variables. In this case, our pointer contains the
0x1000. Because this is the
thing, we say that
thing_ptr points to
Variables and pointers are much like street addresses and houses. For example, your address might be “214 Green Hill Lane.” Houses come in many different shapes and sizes. Addresses are approximately the same size (street, city, state, and zip). So, while “1600 Pennsylvania Ave.” might point to a very big white house and “8347 Undersea Street” might be a one-room shack, both addresses are the same size.
The same is true ...