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 exit() function?
Write a programe print the sum of series 0,1,2,.....10
How can I call a function with an argument list built up at run time?
Which is better malloc or calloc?
What is modeling?
void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(); }
Table of Sudoku n*n
What is function prototype in c with example?
Explain what is the difference between the expression '++a' and 'a++'?
What is the full form of getch?
What are bitwise shift operators in c programming?
Explain how do you override a defined macro?