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.

Recommended Answers

All 2 Replies

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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.