why we need function pointers?

Answers were Sorted based on User's Feedback



why we need function pointers? ..

Answer / 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

why we need function pointers? ..

Answer / naman patidar

Apart from above mentioned usage function pointer are used
by event listeners and callback utilities in multi threaded
applications.

Is This Answer Correct ?    3 Yes 0 No

why we need function pointers? ..

Answer / gajendra

Function Pointers are pointers, i.e. variables, which point to the address of a function. You must keep in mind,
that a running program gets a certain space in the main-memory. Both, the executable compiled program code
and the used variables, are put inside this memory.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

int x=sizeof(!5.856); What will value of variable x?

2 Answers  


write a progam to display the factors of a given number and disply how many prime numbers are there?

2 Answers  


Write down the program to sort the array.

4 Answers   Impiger,


What is the hardest programming language?

0 Answers  


Write a C program that reads a series of strings and prints only those ending in "ed"

2 Answers   Accenture,






What is #include conio h?

0 Answers  


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

0 Answers  


What is the meaning of 2d in c?

0 Answers  


What is the difference between %d and %i?

0 Answers  


What is the c language function prototype?

0 Answers  


Explain argument and its types.

0 Answers  


Why is C language being considered a middle level language?

0 Answers  


Categories