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 |
What is && in c programming?
what is the difference between declaration ,defenetion and initialization of a variable?
find out largest elemant of diagonalmatrix
print out put like this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20
write a program to print sum of each row of a 2D array.
program to convert a integer to string in c language'
What are valid operations on pointers?
What is the use of a conditional inclusion statement in C?
What happens if header file is included twice?
How can I convert integers to binary or hexadecimal?
Write a program of prime number using recursion.
What is a spanning Tree?