What is Function Pointer? Explain with example?

Answers were Sorted based on User's Feedback



What is Function Pointer? Explain with example?..

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

What is Function Pointer? Explain with example?..

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

What is Function Pointer? Explain with example?..

Answer / mahi

pointer is a variable witch can strore address of another
variable

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?

8 Answers   Mascot, TCS,


What are the advantages and disadvantages of c language?

0 Answers  


what is a c-language.what is do.

4 Answers   HCL,


WRITE A C PROGRAM TO FIND SECOND BIGGEST VALUE FROM THE GIVEN VALUES

1 Answers  


Give a method to count the number of ones in a 32 bit number?

4 Answers  






How do I get an accurate error status return from system on ms-dos?

0 Answers  


Is c procedural or functional?

0 Answers  


1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


What does %p mean?

0 Answers  


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).

0 Answers  


HOW TO SWAP TWO NOS IN ONE STEP?

16 Answers   Satyam,


how to find the binary of a number?

10 Answers   Infosys,


Categories