function
is an array of pointers to type data void
. You want to pass it to a pointer to pointers of the type int (*)(int, int)
that will be int (**)(int, int)
, so the following works:
int (*F)(int, int) = ((int (**)(int, int)) functions)[0];
As pointed out by @MM , the above will lead to undefined behavior . You might want to read this article for this as well.
Ideally, you would do something like this:
int (*functions[2])(int, int) = {&foo, &bar};
int (*F)(int, int) = functions[0];
int r = F(3, 4);