Are these 2 lines of code the same ??
line 1:
void (**foo)(int)
line 2
void *(*foo)(int)
Kindly help me understand on what is happening.
CodePudding user response:
They are not the same.
void (**foo)(int);
foo
is a pointer to a pointer to a function that takes an int
parameter and returns void
.
void *(*foo)(int):
foo
is a pointer to a function that takes an int
parameter and returns a pointer to void
.
Postfix operators like ()
and []
have higher precedence than unary *
, so
T *a[N]; // a is an array of pointer to T
T (*a)[N]; // a is a pointer to an array of T
T *f(); // f is a function returning pointer to T
T (*f)(); // f is a pointer to a function returning T