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 C program to count the number of email on text

0 Answers  


What is the difference b/w Structure & Union?

3 Answers  


Define function pointers?

1 Answers  


How can I remove the trailing spaces from a string?

0 Answers   Aspire,


What does sizeof int return?

0 Answers  






wap to print "hello world" without using the main function.

22 Answers   TCS, Wipro,


Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)

1 Answers  


sir i got 146 correct question & i have also the advantage of height so will they consider my marks as 146+3=149.can any body tell me how they consider my height marks.

1 Answers  


List the difference between a 'copy constructor' and a 'assignment operator' in C?

0 Answers   Accenture,


Write a program in C to print the alphabets in order as on a mobile phone.i.e:When 2 is pressed once 'a' prints and if it is pressed two times 'b' prints and so on.we have to print all the alphabets as on mobile phone like this.

1 Answers   Wipro,


Difference between strcpy() and memcpy() function?

0 Answers  


Explain the difference between malloc() and calloc() function?

0 Answers  


Categories