Why we use function pointers?
Eg:
Roughly I written the code for understanding purpose only...
char (*ptr_fun)(); // pointer to a function which returns char
char fun();
char ch;
ptr_fun = &fun; // assign the address of that fun to that pointer
Now the question is, what is the different between the below two function call even though both perform the same operation
ch = fun();
ch = *ptr_fun;
Kindly explain why the function pointers are used and what are the situations it required.
Eg:
Roughly I written the code for understanding purpose only...
char (*ptr_fun)(); // pointer to a function which returns char
char fun();
char ch;
ptr_fun = &fun; // assign the address of that fun to that pointer
Now the question is, what is the different between the below two function call even though both perform the same operation
ch = fun();
ch = *ptr_fun;
Kindly explain why the function pointers are used and what are the situations it required.