Skip to main content
added 526 characters in body
Source Link
Am_I_Helpful
  • 19.2k
  • 7
  • 53
  • 76
  1. a corresponds to the pointer pointing at 0th element of the array. Whereas,the same is the case with &a.It just gives the starting address of the array.

As,a --> pointer pointing to starting element of array a[],it does not know about other element's location..

&a --->address location for storing array a[] which stores first element location,but knows every element's location.

Similarly,other elements location will be (a+2),(a+4) and so upto the end of the array.

Hence,you got such result.

  1. int (*p)[3] is a pointer to the array. had it been int *p[3],it would been meant entirely different. It'd have meant an array of pointers which would have been totally different from this context.

Pointer to an array will automatically take care of all the other elements in the array.In this case,your's is (p);

Whereas,the pointer to the first element of the array,i.e., a will only know about first element of the array.You'll have to manually give pointer arithmetic directions to access next elements.See,in this case---we can get second element from a by adding 2 to a,i.e. a+2,third element by adding 4 to a,i.e., a+4 and so on. // mind the difference of two as it is an integer array!

  1. a corresponds to the pointer pointing at 0th element of the array. Whereas,the same is the case with &a.It just gives the starting address of the array.

As,a --> pointer pointing to starting of array a[].

&a --->address location for storing array a[] which stores first element location.

Similarly,other elements location will be (a+2),(a+4) and so upto the end of the array.

Hence,you got such result.

  1. int (*p)[3] is a pointer to the array. had it been int *p[3],it would been meant entirely different. It'd have meant an array of pointers which would have been totally different from this context.
  1. a corresponds to the pointer pointing at 0th element of the array. Whereas,the same is the case with &a.It just gives the starting address of the array.

As,a --> pointer pointing to starting element of array a[],it does not know about other element's location..

&a --->address location for storing array a[] which stores first element location,but knows every element's location.

Similarly,other elements location will be (a+2),(a+4) and so upto the end of the array.

Hence,you got such result.

  1. int (*p)[3] is a pointer to the array. had it been int *p[3],it would been meant entirely different. It'd have meant an array of pointers which would have been totally different from this context.

Pointer to an array will automatically take care of all the other elements in the array.In this case,your's is (p);

Whereas,the pointer to the first element of the array,i.e., a will only know about first element of the array.You'll have to manually give pointer arithmetic directions to access next elements.See,in this case---we can get second element from a by adding 2 to a,i.e. a+2,third element by adding 4 to a,i.e., a+4 and so on. // mind the difference of two as it is an integer array!

Source Link
Am_I_Helpful
  • 19.2k
  • 7
  • 53
  • 76

  1. a corresponds to the pointer pointing at 0th element of the array. Whereas,the same is the case with &a.It just gives the starting address of the array.

As,a --> pointer pointing to starting of array a[].

&a --->address location for storing array a[] which stores first element location.

Similarly,other elements location will be (a+2),(a+4) and so upto the end of the array.

Hence,you got such result.

  1. int (*p)[3] is a pointer to the array. had it been int *p[3],it would been meant entirely different. It'd have meant an array of pointers which would have been totally different from this context.