In: Computer Science
pointer :- pointer is a variable whose value is the address of another variable.
like if "P" is a pointer and it's value is "2000" and "Q" is the another variable, then if "P" holding the address of "Q". so simply we can say that "2000" is the address of variable "Q" , which is holding by "P".
for using the pointer in a program we have to remember some points :
a) we have to first define a pointer.
b) then we have to assign the address of some variable to pointer.
c) and then access the value at the address which is available in pointer variable
remember pointer is also a variable only.
here is the example:
#include <iostream>
using namspace std;
int main()
{
int var = 50 ; // variable
int *pointer ; //pointer variable
pointer = &var; //store the address of variable in pointer
cout<< "variable's value ";
cout<< var <<endl;
cout<< "address store in pointer";
cout<< pointer<<endl; //this gives the address of "var" which is holding by "pointer"
cout<< "value of the variable whose address hold by pointer";
cout<< *pointer <<endl; //this gives the value of "var"
return 0;
}