Pointer to array of functions in C

arrays, c, definition, function, pointers

Solution

This is not a valid C declaration. First, the type of `a` is missing. But worse than that, it's as if `(*af[10])(int , *a[10][10])` was returning a function (which is impossible).

Maybe you meant:

int (*(*af[10])(int , int *a[10][10]))(int,int)

Which would make `af` an array of 10 pointers to function receiving `int` and an array of 10 arrays with 10 pointers to `int`, and returns a pointer to function receiving two `int`s and returning an `int`.

EDIT:

Looks like the correct line is:

int (*af[10])(int ,int (*a[10][10])(int,int))

This makes `af` an array of 10 pointers to function receiving 2 parameters and returning `int`. The first parameter is an `int`, and the second is a multi-dimensional array (10x10) or pointers to function receiving 2 `int`s and returning an `int`.

In the future, you might want to check out cdecl.org to confirm your guess.

Problem

I have this type of definition ``` int (*af[10])(int , *a[10][10])(int,int) ``` and I had to "translate" it just like "this is pointer to function array size of 10" etc etc. I think that there is a mistake here, cause `*a[10][10]` doesn't have a definition type. Is this correct? Or this line can be translated properly? Thanks in advance Finally I found that the correct definition should be like this ``` int (*af[10])(int ,int (*a[10][10])(int,int)) ``` which is correct and makes sense.

Original source