Arrays of Pointers

  • The way there can be an array of ints or an array of floats, similarly there can be an array of pointers. Since a pointer variable always contains an address, an array of pointers would be nothing but a collection of addresses. The addresses present in the array of pointers can be addresses of isolated variables or addresses of array elements or any other addresses. All rules that apply to an ordinary array apply to the array of pointers as well. 

  • An array of pointers can even contain the addresses of other arrays.

  • Example:



  • An array is similar to an ordinary variable except that it can store multiple elements of similar type. 

  • Compiler doesn’t perform bounds checking on an array. 

  • The array variable acts as a pointer to the zeroth element of the array. In a 1-D array, the zeroth element is a single value, whereas, in a 2-D array this element is a 1-D array. 

  • On incrementing a pointer it points to the next location of its type. 

  • Array elements are stored in contiguous memory locations and so they can be accessed using pointers. 

  • Only limited arithmetic can be done on pointers.