Read the value of the original variable through the pointer. - C++ Data Type

C++ examples for Data Type:Pointer

Description

Read the value of the original variable through the pointer.

Demo Code

#include <iostream>

using namespace std;

int main()//w  ww  .j a  v  a 2 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;
}

Result


Related Tutorials