C++ Pointer Access value using pointers
#include <iostream> using namespace std; int main()//from w w w . jav a 2 s . co m { int var1, var2; int* ptr; //pointer to integers ptr = &var1; //set pointer to address of var1 *ptr = 37; //same as var1=37 var2 = *ptr; //same as var2=var1 cout << var2 << endl; //verify var2 is 37 return 0; }