I'm stuck in getting a function pointer back from a function parameter. Here's an example of what I'm trying to do.
int a(int I)
{
return I*I;
}
void get_a(int(*R)(int))
{
R = &a;
}
int main()
{
int(*function)(int) = NULL;
printf("function a=%p\n", a);
get_a(function);
printf("function a=%p\n", &function); // Is never the right address.
return 0;
}
Searching the net did not help, I could only find examples of pass a function as parameter, so I gave up and tried solving this problem by myself.