The code below shows the reference to function pointer:
typedef int (*t_somefunc)(int,int);
int product(int, int);
int main(void) {
t_somefunc afunc = &product; // "product" works fine without "&"
What do we use "&" for referencing function pointer?
See full working code:
#include <stdio.h>
typedef int (*t_somefunc)(int,int);
int product(int, int);
int main(void) {
t_somefunc afunc = &product; // product without & works also
int x2 = (*afunc)(123, 456); // call product() to calculate 123*456
printf("x2 value is %d\n", x2);
return 1;
}
int product(int u, int v) {
return u*v;
}