| Previous | Home | Next |
Example:
#include<iostream.h>
int main()
{
int firstval=5, secondval=15;
int *p1,*p2;
p1=&firstval; //p1=address of firstval
p2=&secondval; //p2=address of secondval
*p1=10; //value pointed y p1=10
*p2=*p1; //value pointed y p2=value pointed y p1
p1=p2; //value of pointer is copied
*p1=20; //value pointed by p1=20
cout<<"firstval is"<<firstval;
cout<<"secondval is"<<secondval;
return 0;
}
Output:
first value is 10 second value is 20
| Previous | Home | Next |