Here is an example:
#include <stdio.h>
int function_a(int a, int b)
{
printf("Inside function_a: %d %d\n", a, b);
return a+b;
}
int function_b(int a, int b)
{
printf("Inside function_b: %d %d\n", a, b);
return a+b;
}
int function_c(int a, int b)
{
printf("Inside function_c: %d %d\n", a, b);
return a+b;
}
int function_whatever(int a, int b)
{
printf("Inside function_whatever: %d %d\n", a, b);
return a+b;
}
int (* get_function(char c)) (int, int)
{
switch(c)
{
case 'A':
return function_a;
case 'B':
return function_b;
case 'C':
return function_c;
}
return function_whatever;
}
int main(void) {
get_function('B')(3, 5);
return 0;
}
get_function('B') returns a function pointer to function_b and get_function('B')(3, 5); also calls that function.
https://ideone.com/0kUp47
int (* get_function(char c)) (int, int);is not a function pointer, it is a function, getting achar cand returning a pointer to a function.