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 |
Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?
What are the advantages and disadvantages of c language?
what is a c-language.what is do.
WRITE A C PROGRAM TO FIND SECOND BIGGEST VALUE FROM THE GIVEN VALUES
Give a method to count the number of ones in a 32 bit number?
How do I get an accurate error status return from system on ms-dos?
Is c procedural or functional?
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
What does %p mean?
Given an array A[n+m] of n+m numbers, where A[1] ... A[n] is sorted and A[n+1] ... A[n+m] is sorted. Design a linear time algorithm to obtain A[1...n+m] sorted using only O(1) extra space. Time Complexity of your algorithm should be O(n) and Space Complexity O(1).
HOW TO SWAP TWO NOS IN ONE STEP?
how to find the binary of a number?