Function pointers are little complicated and many people ask about the right way to define this type of pointer.
- use typedef
- start with a function, then add the *.
lets try it: lets create a function that returns a pointer and receive two variables:
void * myFunction (int x, int y);
Now, to make it a pointer (very easy!) surround the function name with parentheses and right after the opening of the parentheses, put the * sign, like so:
void * (*myFunction) (int x, int y);
Here you go – a function pointer. But who wants to type this every time?
So, we are using this:
typedef void * (*myFunction) (int x, int y);
and now, myFunction is a declared type.