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 |
Write a function in c to find the area of a triangle whose length of three sides is given.
please send me the code for multiplying sparse matrix using c
wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
Can u return two values using return keyword? If yes, how? If no, why?
How to write a code for reverse of string without using string functions?
Write a program of prime number using recursion.
write a prgram of swapping with 2 valiables
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
program for following output using for loop? 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
program in c to print 1 to 100 without using loop
How main function is called in c?