Multi dimensional Arrays and Pointers

Discussion in 'C' started by God_Gracious, Jun 13, 2011.

  1. God_Gracious

    God_Gracious New Member

    Jun 13, 2011
    Likes Received:
    Trophy Points:
    Respected SIR,
    C compiler decays Two dimensional arrays into a pointer to the one dimensional array! Then how can the pointer arithmetic be applied to the two dimensional array?

    Eg. If array is - int a[2][2]
    and it gets decayed into something like this- int (*p) [2] - a pointer to the a dimensional array with two integer elements,then how can this a[2][2] be accessed by pointer arithmetic-
    *(*(a+1) +1)
    it must use a[1][1] because there is no further decay of the two dimensional array to pointer to pointer

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice