C multi-dimensional arrays and pointers

From: Richard Hayden (rah03_at_doc.ic.ac.uk)
Date: 11/01/04


Date: Mon, 01 Nov 2004 22:38:41 +0000

Hi,

Why does gcc (3.3.2) give me a 'initialization from incompatible pointer
type' warning when compiling:

int main(int argc, char** argv) {
        int testa[2][2];
        int** testp = testa;
}

Whereas the following code works without warnings:

int main(int argc, char** argv) {
        int testa[2];
        int* testp = testa;
}

I thought that multi-dimensional arrays were implemented as arrays of
pointers to arrays of pointers?

Any insight gratefully appreciated!

Thanks,

Richard Hayden.



Relevant Pages