How to create a typedef for function pointers

Your question isn’t clear, but I think you might want something like this:

int foo(int i){ return i + 1;}

typedef int (*g)(int);  // Declare typedef

g func = &foo;          // Define function-pointer variable, and initialise

int hvar = func(3);     // Call function through pointer

Leave a Comment