Arrays vs. Pointers
Arrays vs. Pointers

The difference is relatively straight forward. When you declare a pointer, space is allocated to hold an address of the specified type. When an array is declared the same thing happens, EXCEPT this time in addition to the variable allocated to hold the address, memory is allocated to hold the array itself. So if you declare:

int *array; A varaible is created to hold the address of an integer variable. Now if we were to declare the following: int array[15]; The variable array is created but there is also a block of memory allocated to hold 15 integers. See the difference?


Main Page
Last Modified 31 October 2000