Skip to content

Instantly share code, notes, and snippets.

@atul161
Created May 24, 2020 16:18
Show Gist options
  • Save atul161/43dc43057ea8a442297660fd2f62da27 to your computer and use it in GitHub Desktop.
Save atul161/43dc43057ea8a442297660fd2f62da27 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int main(){
//Normal variable declartaion which have value 10.
int i = 10;
//pointer declaration of int type and store the address of i variable
int *p = &i;
// value of i is 10
cout<<i;
//here p is pointer so it will print the address of i
//ex : 0xab123dee23
cout<<p;
//Here we are printing the address of a pointer varaible
//Every variable have address, pointer variable stores the address of another variable
// So pointer is also a kind of variable that's why p also have its own address
//ex:0xff32eea23
cout<<&p;
//If we want to print the value associated with the
//adddress, which is store in pointer variable then we will use *
//Here *p will print 10
cout<<*p;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment