I am having hard time understanding function pointers and the syntax associated with it. I looked online and read a bit and I all could understand are simple scenarios. I am not able to extend it.
What I understand is below scenario wherein a function's address is passed to a pointer and we use it for future reference.
int GetSomething(char *);
typedef int (*pGetSomething)(char *);
int main(void)
{
char * what = "I atleast got this";
pGetSomething pfGetSomething;
pfGetSomething = &GetSomething;
pfGetSomething(what);
return 0;
}
int GetSomething(char *format)
{
printf("%s \n \n ", format);
return 0;
}
Now Lets say I want to extend this further such that -
PGetSomething calls a Void function and returns me address to a function which has argument of char* and return type int.
I tried below syntax and tried to return a pointer to GetSomething. But I guess I am clueless how to approach. All I could muster was below syntax. Can someone help me understand what would be required to achieve something like as mentioned with a code snippet if possible ?
typedef int (*pGetSomething(void))(char *);