why we need function pointers?

Answer Posted / kirankumaryakkala

a pointer that holds the address of a function.
in writing the interrupt service routines(isr),memory virus
programs, etc..
as simply, if u wanna execute one function out of two or
more funcitons( the selection based dynamically)

ex. int add(int a, int b)
int sub(int a, int b)
int mul(int a, int b)

int (*ptr)(int a, int b) //function pointer declaration to
hold a function that takes two integers, returns one integer

here,
ptr= it can assign any function name that is going to execute


Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which of these functions is safer to use : fgets(), gets()? Why?

633


Explain the difference between the local variable and global variable in c?

600


What is dynamic dispatch in c++?

554


What are reserved words with a programming language?

601


What is the purpose of macro in C language?

659






What is the scope of static variables in c language?

626


What is void main ()?

609


Write a program to generate random numbers in c?

660


What is the function of multilevel pointer in c?

668


What are valid signatures for the Main function?

701


How do you define structure?

563


Is main is a keyword in c?

606


What is the advantage of c?

609


Explain main function in c?

624


What is scope of variable in c?

562