Hello all, long time since i've posted anything here. Working on a small project and nearing the end; however i am having some trouble regarding pointers to 'multidimensional' arrays, hopefully somebody can help me out. :)

I have what i think is an array of 2D arrays of which I am trying to assign a array of pointers to each 2D array.

char (matrix[2][2])[22]; //an array of 22 2x2 arrays
char (*pntr[22])[2][2]; //an array of 22 pointers to a 2x2 array of chars
pntr[0] = matrix[0];

To my current understanding this should assign the first pointer to the first array of 2d arrays; however i am still getting the compiler error "Warning: assignment from incompatable pointer type" & program crashes when i try and acess data pointed to by 'pntr'. Any help & an explanation as to what i am doing wrong would be greatly appreciated, thanks in advance.

8 Years
Discussion Span
Last Post by lecotti

An array of 22 2x2 arrays is declared char matrix[22][2][2];

Ugh, how careless of me. I need to get more sleep...
Thanks anyhow!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.