Demo code for using function pointers in c:
What is the output of below C program.
fp = fun;
crash at run time
compile time error, invalid operation.
This is an example of how to use function pointers. fp is the function pointer which stores the address of function fun(). so on calling (*fp)(); it is indirectly calling the function fun(). if fp is a function pointer, it is not mandatory to call like (*fp)(). we can call directly fp(); both are same. so it prints function.
Back To Top