This declaration
char (*table)[c][r];
does not declare an array. It is declares a pointer to an object of type char[c][r]
. By the way why is not ?:)
char[r][c]
^^^^^
Thus before using this pointer it shall be correctly initialized.
In this function declaration
void build_field(char *table ,int tamanhox, int tamanhoy);
the first parameter has type char *
. Types char ( * )[c][r]
and the type char *
are different incompatible types.
You could write the function declaration for example the following type
void build_field( int tamanhox, int tamanhoy, char ( *table )[tamanhox][tamanhoy] );
But inside the function you have to dereference the pointer. For example
( *tablw)[I][j]
The exact parameter declaration depends on how the pointer is initialized and what you are going to do. Maybe you mean the following declarations
char (*table)[r];
and
void build_field( int tamanhox, int tamanhoy, char ( *table )[tamanhoy] );
The compiler issues an error because the function parameter table
has type char *. So table[I]
is a scalar object of type char
. Hense you may not apply to it the subscript operator like table[I][x]
. And moreover this expression
table[tamanhoy][tamanhox]
^^^^^^^^ ^^^^^^^^^
in any case does not make sense because at least you should write
table[i][x]
^^^^^^