Created
November 5, 2013 09:05
-
-
Save Codeplaza/7315967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main () | |
{ | |
int firstvalue = 5, secondvalue = 15; | |
int * p1, * p2; | |
p1 = &firstvalue; // p1 = address of firstvalue | |
p2 = &secondvalue; // p2 = address of secondvalue | |
*p1 = 10; // value pointed by p1 = 10 | |
*p2 = *p1; // value pointed by p2 = value pointed by p1 | |
p1 = p2; // p1 = p2 (value of pointer is copied) | |
*p1 = 20; // value pointed by p1 = 20 | |
cout << "firstvalue is " << firstvalue << endl; | |
cout << "secondvalue is " << secondvalue << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment