Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 17, 2020 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/515caa6c23b9ac15576e09340c190a30 to your computer and use it in GitHub Desktop.
Save amankharwal/515caa6c23b9ac15576e09340c190a30 to your computer and use it in GitHub Desktop.
int var = 20;
int *ptr;
ptr = &var;
cout << var << endl;
//Outputs 20 (The value of var)
cout << ptr << endl;
//Outputs 0x234f119 (var's memory location)
cout << *ptr << endl;
//Outputs 20(The value of the variable stored in the pointer ptr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment