I have this code:
// *** foo.c ***
#include <stdlib.h> // malloc
typedef struct Node {
char (*f)[20];
//...
} Node;
int function(char f[30][20]){
// Do some stuff with f...
}
int main(){
Node * temp = (Node*)malloc(sizeof(Node));
function(temp->f[20]);
}
I would like to pass temp->f
array pointer to function, but on compile I get these errors:
$ gcc foo.c -o foo
foo.c: In function ‘main’:
foo.c:16:5: warning: passing argument 1 of ‘function’ from incompatible pointer type [enabled by default]
function(temp->f[20]);
^
foo.c:10:5: note: expected ‘char (*)[20]’ but argument is of type ‘char *’
int function(char f[30][20]){
^
How can I fix it?