C error Array: array type has incomplete element type.

arrays, c

Solution

You will have to know what the function is actually expecting and modify the interface accordingly. If it is expecting a bidimensional array (`char [N][M]`) the correct interface would be:

extern int docx(char *,char*[M]);

Which is different from:

extern int docx( char*, char** );

In the first case the function would be expecting a pointer into a contiguous block of memory that holds `N*M` characters (`&p[0][0]+M == &p[1][0]` and `(void*)&p[0][0]==(void*)&p[0]`), while in the second case it will be expecting a pointer into a block of memory that holds `N` pointers to blocks of memory that may or not be contiguous (`&p[0][0]` and `&p[1][0]` are unrelated and `p[0]==&p[0][0]`)

// case 1
ptr ------> [0123456789...M][0123.........M]...[0123.........M]

// case 2
ptr ------> 0 [ptr] -------> "abcde"
            1 [ptr] -------> "another string"
              ...
            N [ptr] -------> "last string"

Problem

I have: ``` extern int docx(char *,char[][]) // in a header file ``` It is compiled properly in solaris, but in Redhat Linux it shows the error bellow: ``` array type has incomplete element type. ``` I know i can solve it as - `char[][20]` Is it the right way?

Original source