C++ Pointer Read variable's value via pointer.

Description

C++ Pointer Read variable's value via pointer.

#include <iostream>

using namespace std;

int main()//from w w  w.  ja  v  a2 s  . c o m
{
  int a = 10;
  int *ptr = &a;
  int backup;
  *ptr = 200;

  backup = *ptr;
  cout << backup << endl;

  *ptr = 7000;
  cout << *ptr << endl;
  cout << backup << endl;
  return 0;
}



PreviousNext

Related