Function Pointer is a pointer which points to a function with different names but similar type of parameters. The Functions which performs different operations but still having same parameters as each other at that time function pointer are very useful for accessing functions in a flexible manner.
If there is one function called
addition(int a, int b); & another function RectArea(int length, int width);
These both functions are performing different tasks but still have same parameters.
Now just we have to careful how the Function Pointer will know to call which function
It is done by
void (*function_pointer) (int, int) // Function pointer Declaration
function_pointer = &function_name; // assigning Address of a Function
(*funcation_pointer) (num1,num2); // call to an assinged function.
As per above example
void (*fptr) (int, int);
fptr = &addition; // Call to Addition Function
fptr = & RectArea; // Call to Area of Rectangle Function.
(*fptr) (length, width);
by Adrian McDonald5 years ago
I'm a film director and screen writer who is currently working on my first film. I would appreciate the input of everyone on this topic. It doesn't matter how absurd your idea may be, many absurdities have revealed...
by karzan.ahmad7 years ago
calculute [(sin x)^1/2]dx?
by brian cruz8 years ago
5 function in C language(give at least 5) and their definition
Copyright © 2018 HubPages Inc. and respective owners.
Other product and company names shown may be trademarks of their respective owners.
HubPages® is a registered Service Mark of HubPages, Inc.
HubPages and Hubbers (authors) may earn revenue on this page based on affiliate relationships and advertisements with partners including Amazon, Google, and others.