Interview Question
Country: United States
array of pointers : int *p[] ( This is a 2D array )
pointer to array : int *p=a (here 'a' is an array of integers)
An array of pointers is an array, where the elements are pointers to some memory location.
for eg-
it would be something like
int* parr[10];
here parr[0],parr[1],etc are pointer variables
A pointer to an array is when a pointer is pointing to the starting address of an array.
eg, let int arr[10] be an array. A pointer that points to arr[0], would be a pointer to an array
A pointer is a datatype, which stores the memory address of any datatype. The size of the pointer depends on the architecture of the system - a 32-bit system would have a pointer size of 32 bits to accommodate a memory address space of 4GB, a 64-bit architecture should use 64 bits for pointer data type. An array of pointers is an array of such address-holding datatypes.
- Murali Mohan July 30, 2013Whereas a pointer to an array points to the (typically first) address of an array of locations which store a particular datatype, say ints, chars, etc, including pointers.