As we have seen, elements of arrays can always be accessed via indices and traversed by means of an integer offset from the zeroth element. Sometimes, however, it is more convenient to access array elements via a pointer equivalent.
Let's begin by declaring an array and two pointers, as follows:
const int arraySize = 5;
int array[5] = { 1 , 2 , 3 , 4 , 5 };
int* pArray1 = NULL;
int* pArray2 = NULL;
We have declared a contiguous block of arraySize, or 5, which are elements that are integers. We don't use arraySize in the array declaration because the array cannot be initialized as array in this way, even thougharraySize is a constant. We have also declared two pointers to integers—pArray1 and pArray2. In the memory on my system, this looks something like the following:
Remember that we can't control the ordering or location of variables, but we...