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

While compiling a c program,graphics header files are not including in my program..eg: <graphics.h>,what may be the problem...is there any environment settings exists.

2 Answers  


When should we use pointers in a c program?

0 Answers  


How arrays can be passed to a user defined function

0 Answers  


What are runtime error?

0 Answers  


Two's compliment of -5

4 Answers   Adobe,






how to capitalise first letter of each word in a given string?

0 Answers  


do you think its fraud or original company?

0 Answers  


what is self refrential structure

3 Answers   HCL,


who will call your main function in c under linux?

2 Answers  


int a[3][5]={ {1,2,3,4,5],{2,3,4,5,6},{10,11,12,13,14}}; int *p=&a; printf(ā€œ%dā€,*(*(x+1)+3));

2 Answers   Wipro,


#include<stdio.h> int main(){ int a[]={1,2,3,5,1}; int *ptr=a+4; int y=ptr-a; printf("%d",y); }

3 Answers   Zoho,


main() {int a=200*200/100; printf("%d",a); }

14 Answers   TCS,


Categories