I'm trying to get this code to run..
#include <stdio.h>
int *myMethod(int *a)
{
printf("Hello");
return a;
}
int main()
{
// my_ptr is a pointer to function myMethod()
int *my_ptr(int *) = myMethod;
// Invoking myMethod() using my_ptr
int a = 5;
int *p = (*my_ptr)(&a);
printf("Bye %d\n", *p);
return 0;
}
I thought my syntax for a function pointer, my_ptr, would be correct where it could take an int pointer as it's parameter and return an int pointer but when I compile it, I get the error that:
error: function 'my_ptr' is initialized like a variable
int *my_ptr(int *) = myMethod;
Could someone explain the error/issue? Thanks!