What is the difference between these two function pointer notations in C?
void (*a[]()) and void (*a)()[]
Do they both represent same - a as an array of pointers to functions - or does the second one represent a pointer to an array of functions?
How should I call these functions -
say void (*a[]()) = {swap, add, sub, prod};?
Does that mean that a is an array of function pointers of 4 elements and swap, add, sub, prod's address are there in the a[0]...a[3].
How should I invoke these functions, like this?
*a[i]()
or like this?
a[i]()
Use cdecl.org to figure this stuff out until you can do it without thinking about it.
void (*a[]()): declare a as array of function returning pointer to void
whereas
void (*a)()[]: declare a as pointer to function returning array of void
The latter is invalid C.
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