Program showing the usage of Function Pointer
Output
-------------
/*
name : main.cpp
Calling a function using function pointer
*/
#include <stdio.h>
int main()
{
int display();
int (*func_ptr)(); ///Declare function Pointer
func_ptr = display; /// Assign address of function
printf("\n Address of function display is %u", func_ptr); ///Printing Address of function
(*func_ptr)(); /// Invokes the function display
getchar(); ///Get char for seeing the output
return 0;
}
int display()
{
puts("\n Hello World !!\n");
return 1;
}
Output
-------------