How do you initialize function pointers? Give an example?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why can’t constant values be used to define an array’s initial size?

964


Explain what is wrong with this program statement?

736


find out largest elemant of diagonalmatrix

1757


What are the 5 types of inheritance in c ++?

675


Does c have an equivalent to pascals with statement?

657






What are derived data types in c?

704


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3332


How many levels deep can include files be nested?

755


Write a program to swap two numbers without using third variable in c?

713


explain how do you use macro?

763


Explain how do you determine whether to use a stream function or a low-level function?

726


find the sum of two matrices and WAP for it.

746


Is it possible to use curly brackets ({}) to enclose single line code in c program?

921


Write a program for Overriding.

811


What is line in c preprocessor?

698