If I want to define a pointer variable p to point to the function foo() defined as below, what should be the exact type of p?
int *foo(void *arg)
{
...
}
It should be
typedef int *(*funtion_foo_type)(void *);
You need to have the pointer as the pointer to a function, returning an int *, accepting a void* argument. You can make it like
int * (*p) (void *);
and then, you can use
p = foo;
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