what is the advantage of function pointer
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
Tell me what is null pointer in c?
what is the difference between declaration ,defenetion and initialization of a variable?
Explain how do you print only part of a string?
What is an endless loop?
what is the use of a array in c
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures
how to find the size of the data type like int,float without using the sizeof operator?
What is data structure in c language?
What is the use of define in c?
What is dynamic variable in c?
What is a macro in c preprocessor?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping