R
ranjmis
Hi all,
I have come across a piece of code wherein a function returns a
function pointer as it seems to me but not very clear from the
prototype.
As shown below - although return type is void - (*master())() returns a
function pointer some_func & meanwhile calls that function and prints
the message "hi from some_func"
please help in interpreting this definition of "master" "function"
-------------------
#include<stdio.h>
void some_func()
{
printf("hi from some_func");
}
void (*master())(int)
{
return some_func;
}
int main()
{
(*master())(7);
return 0;
}
---------------------
I have come across a piece of code wherein a function returns a
function pointer as it seems to me but not very clear from the
prototype.
As shown below - although return type is void - (*master())() returns a
function pointer some_func & meanwhile calls that function and prints
the message "hi from some_func"
please help in interpreting this definition of "master" "function"
-------------------
#include<stdio.h>
void some_func()
{
printf("hi from some_func");
}
void (*master())(int)
{
return some_func;
}
int main()
{
(*master())(7);
return 0;
}
---------------------