How do you initialize function pointers? Give an example?

Answers were Sorted based on User's Feedback



How do you initialize function pointers? Give an example?..

Answer / vadivel t

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

How do you initialize function pointers? Give an example?..

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

How do you initialize function pointers? Give an example?..

Answer / vadivel t

Sorry the above function pointer declaration should be like
this

(*pfunc)(int, int);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****

2 Answers  


O,T,T,F,F,S,S,E,N,?,?,?,T,F,F,S,S,E,N

9 Answers   ADP,


What is the acronym for ansi?

0 Answers  


What is the use of structure padding in c?

0 Answers  


I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed

4 Answers   Aspire,






code for replace tabs with equivalent number of blanks

0 Answers   Bosch,


What are the 5 elements of structure?

0 Answers  


write a program in c language to print your bio-data on the screen by using functions.

0 Answers  


I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?

3 Answers  


Write a program to show the workingof auto variable.

2 Answers   Infotech,


write a program to produce the following output; ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A

17 Answers   ABC, College School Exams Tests,


design and implement a program that reads floating-points numbers in a sentinel-controlled loop until the user terminates the program by entering zero.your program should determinate and print the smallest,largest and average of the supplied numbers.

2 Answers  


Categories