A question from interview, so I wrote a test program to demonstrate.
Func is a function pointer. the return value of this function is int without any input parameters. Then, the main program declares a function pointer myfuncpointer, which indicates that the input parameter of the function pointer represents an int, the return value is also a function pointer, And the type is func type. So we can assign the func2 function to the pointer of myfuncpointer. The question of interview is the declaration of myfuncpointer.
# Include <stdio. h>
Typedef int (* func )();
Int func3 ()
{
Printf ("in function 3... \ n ");
Return 0;
}
Func func2 (int)
{
Printf ("input parameter is: % d \ n", );
Return func3;
}
Int main ()
{
Func (* myfuncpointer) (INT) = func2;
Func returnvalue = myfuncpointer (1111 );
Int func3_return = returnvalue ();
Printf ("func3 return value is: % d \ n", func3_return );
Return 0;
}