How do you initialize function pointers? Give an example?
Answers were Sorted based on User's Feedback
Initialisation can be done in the following way.
func(int a,int b);
*pfunc(int a, int b);
main()
{
/*here the starting address of the function can be assigned
to a function pointer of the same type*/
pfunc = func;
....
....
....
}
func(int a, int b)
{
....
....
....
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / preeti singh
for e.g. if we have to declare a pointer to a function , the
signature of which is :
int add(int a,int b)
then a pointer to the above function can be declared as:
int (*myptr)(int ,int);
here myptr is a pointer which can point to any function that
takes 2 int args and returns an int value.
| Is This Answer Correct ? | 1 Yes | 1 No |
WHO WROTE C LANGUAGE?
who is the father of C Language?
20 Answers CTS, UST,
C passes By value or By reference?
5 Answers Geometric Software, Infosys,
How can I invoke another program or command and trap its output?
What is structure padding ?
Do variables need to be initialized?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
1 Answers Amdocs, Apps Associates,
What is a class?
write a program to insert an element at the specified position in the given array in c language
What are the differences between Structures and Arrays?
What is the difference between char a[] = "string"; and char *p = "string"; ?
14 Answers Adobe, Honeywell, TCS,
How many main () function we can have in a project?