What is the difference b/w pointer to array& array to pointer?

This question is related to BirlaSoft Interview

Showing Answers 1 - 2 of 2 Answers

Arun kumar

  • Mar 9th, 2007

pointer to the array is the base address or the location of the first element of the array while the  array to the pointers is the storage for the saving of the pointers in the array.

  Was this answer useful?  Yes

Ptr2Arr (say of Ints):

int *p[10];
p is a Pointer to (First) Array of 10 integers.
May be there are more Such Arrays, and when p++ is done, it starts pointing to next Array.
in that case (p+2)[3] is actually 3rd array's 4th element. 

ArrOfPtrs (say to Int):
int *(p[10]);
p is an Array of 10 pointers to integers.
May be there are pointers, each pointing to head of a different linklist.
p[0] will point to head of first LL and p[1], to head of 2nd... and so on...
in that case, p[4]+3, will point to 3rd node from head(head->next->next->next), in 5tn link list. 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions