You guys are brothers?
Well, if you noticed with the lesson How
do I point to the neighbor?, arrays and pointers are very closely
linked. In fact, they are kind of like brothers.
Let's say we have two brothers. One brother finds a girl,
settles down with her, and stays with that woman for the rest of his
natural life. He is very constant. The other brother is the complete
opposite. He might stay with a woman for a day, a week, a month, or
maybe a couple of years. He might somewhere in his life settle down,
but he doesn't stick with only one girl. Well this is the same with
pointers and arrays.
An array is really just a constant pointer. When you declare
an array like:
ramon is actually a pointer that constantly points
at the beginning of the array. We cannot point ramon somewhere
else. To make a const pointer we would type:
const int *tony;
This will create a const pointer called tony. Once
we initialize where tony will point, we cannot point him somewhere
else or his wife will be mad... I mean the compiler will give you an
But, remember the wild brother can always point to the
paul = ramon;
Now, paul and ramon are pointing to the
same thing; the first element of the array.