What is Function Pointer? Explain with example?
Answers were Sorted based on User's Feedback
Answer / inderchauhan
A pointer is a special kind of variable in C and C++ that
holds the address of another variable.
my first pointer
#include <iostream>
using namespace std;
int main ()
{
int firstvalue, secondvalue;
int * mypointer;
mypointer = &firstvalue;
*mypointer = 10;
mypointer = &secondvalue;
*mypointer = 20;
cout << "firstvalue is " << firstvalue << endl;
cout << "secondvalue is " << secondvalue << endl;
return 0;
}
firstvalue is 10
secondvalue is 20
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sanjay bhosale
function pointer is simply a pointer which holds the address of the function so we can call that function by using pointer.
It is helpful in situations where we are required to pass the function pointer as parameter to some previously defined functions.
for e.g.
in comparison method we may pass function pointer for function which will compare 2 items/objects and help to comparison method.
| Is This Answer Correct ? | 0 Yes | 0 No |
write a program to print calender using for loop.
What is static memory allocation?
What is the use of keyword VOLATILE in C?
What is the hardest programming language?
What do you mean by dynamic memory allocation in c? What functions are used?
Write a program to find whether the given number is prime or not?
Can an array be an Ivalue?
What's the right way to use errno?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What does != Mean in c?
What are loops in c?
how to add our own function in c library please give details.?