Array of pointer and pointer to an array in c

Array of pointer
 each element of array contains the address of memory location is called  array of pointer .each index      treated as a pointer

 Ex-
  main()
   {
      int *arr[4] ;
      int a,b,c,d;
      arr[0]=&a;
      arr[1]=&b;
       arr[3]=&c;
       arr[4]=&d;
   }

 All elements of this array is containing address of these variable .

Pointer to an array

pointer to an array is a pointer which can point whole array and in simple way we can say the base address of and array is Pointer to an array.
                                     since using  base address we can access the whole array that means base address of a array points to whole array .

Ex :_

    main()
     {
         int array[6] ={1,2,3,4,5,6,};
          int *point ;
        point =array // Pointer to an array

    }
 






Share on Google Plus

0 comments: