What is Function Pointer? Explain with example?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c is called a middle level language?

845


How can I do graphics in c?

799


What is pointer to pointer in c language?

815


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2137


How was c created?

825


What is the function of multilevel pointer in c?

862


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1768


What is the most efficient way to count the number of bits which are set in an integer?

844


How many main () function we can have in a project?

901


Why is struct padding needed?

840


What does 1f stand for?

875


What is string constants?

918


What is modeling?

841


How are structure passing and returning implemented?

801


Is there any demerits of using pointer?

833