I'm having really hard time comprehending the syntax for function pointers. What I am trying to do is, have an array of function pointers, that takes no arguments, and returns a void pointer. Can anyone help with that?
First off, you should learn about cdecl
:
cdecl> declare a as array 10 of pointer to function(void) returning pointer to void
void *(*a[10])(void )
You can do it by hand - just build it up from the inside:
a
is an array:
a[10]
of pointers:
*a[10]
to functions:
(*a[10])
taking no arguments:
(*a[10])(void)
returning void *
:
void *(*a[10])(void)
It's much better if you use typedef
to make your life easier:
typedef void *(*func)(void);
And then make your array:
func a[10];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With