what is the advantage of function pointer

Answers were Sorted based on User's Feedback



what is the advantage of function pointer..

Answer / dwight schrute

suppose u have 2 files:

file1 has following functions:
A1
B1
C1

file12 has following functions:
A2
B2
C2

scenario:
A1 needs to use A2 in turn A2 needs to use B1.
A1 invokes A2;
A2 invokes B1;

for B1 to be available in file2 either shld be extern or in
header file which in turn exposes it to entire file2.
In order to minimize this exposure "pass B1 as a functional
pointer to A2".

Is This Answer Correct ?    4 Yes 1 No

what is the advantage of function pointer..

Answer / chikani sagar

TO implement call back functions......It is more efficient.
code complexity will be redused.....

Is This Answer Correct ?    3 Yes 1 No

what is the advantage of function pointer..

Answer / sanjeeva rao

It is useful when you want to send function as argument to
another function. And to implement the call back functions in multi-threading programming.

Is This Answer Correct ?    1 Yes 1 No

what is the advantage of function pointer..

Answer / tahir ali

As you probably learned in your first programming courses,
pointers to variables allows you to modify variable contents
from a non-local environment. This gives the flexibility of
writing generic functions which do not alter "known" global
variables, but references to "unknown" variables. Such
functions can be reused. Function pointers gives you the
same flexibility, but at a higher level. Instead of calling
a "known" function, one can call any arbitrary "unknown"
function. This is the main advantage of function pointers:
greater flexibility and better code reuse.

Is This Answer Correct ?    0 Yes 0 No

what is the advantage of function pointer..

Answer / sudeep reddy

function pointers can be used to replace switch/if
statements,to realize late binding(virtual function tables)
or to implement callback function primitives.

Is This Answer Correct ?    0 Yes 0 No

what is the advantage of function pointer..

Answer / rajesh

code complexcity is less

Is This Answer Correct ?    31 Yes 38 No

Post New Answer

More C Interview Questions

write a programme that inputs a number by user and gives its multiplication table.

2 Answers  


#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?

4 Answers   Ramco,


What is data structure in c language?

0 Answers  


why return type of main is not necessary in linux

0 Answers   TCS,


Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter words-1 3-letter words-1 4-letter words-4

1 Answers   Mind Tree, TCS,






What do header files do?

0 Answers  


#ifdef TRUE int I=0; #endif main() { int j=0; printf("%d %d\n",i,j); }

3 Answers   ADITI,


What is an object?

5 Answers  


What is methods in c?

0 Answers  


compare array with pointer?

1 Answers  


write a program in 'c' to find the value of p[i+1]^n.p,i,n are arguments of a macro and n is a integer

1 Answers  


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


Categories