yandex
loader

please wait

  • Dilpreet Kaur Mar-11-2019 07:34:27 AM ( 1 week ago )

     

    I'm going through a code where I encountered this line of code. I'm not able to understand unsigned char (*data)[int][int] declared as argument in the function, if I consider this piece of code as an array of two-dimensional arrays(I'm passing array of 2d arrays) and then if I modify the code as unsigned char *data[int][int] should this not work?.

  • Dipti Singh Mar-11-2019 07:36:37 AM ( 1 week ago )

    No, it won't work. Because these declarations declare different types which are incompatible.

    unsigned char (*data)[2][2]: declare data as pointer to array 2 of array 2 of unsigned char

    +---+      +---+---+
    |  -+----->|   |   |
    +---+      +---+---+
    data       |   |   |
               +---+---+
               unsigned char [2][2]

    unsigned char *data[2][2]: declare data as array 2 of array 2 of pointer to unsigned char

                      +---+---+
     unsigned char <---+-  |  -+---> unsigned char
                       +---+---+
     unsigned char <---+-  |  -+---> unsigned char
                       +---+---+
                         data


     

     

     

     

     

Please login

Similar Discussion

Recommended For You