forked from codebloded/BackToBasics.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer.cpp
More file actions
23 lines (18 loc) · 682 Bytes
/
pointer.cpp
File metadata and controls
23 lines (18 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
using namespace std;
int main(){
int a = 3;
// This is how an poiter is declared this line means the variable 'ptr' holds the address of variable 'a'
int *ptr = &a;
//Here the & ----> This is a address of operator
cout<<"The address of a is :"<<&a<<endl;
cout<<"The adddress of a is :"<<ptr<<endl;
//here the * ---> (value at) Dereferencing opreator
cout<<"The value of ptr at adddres a is "<<*ptr<<endl;
//**************POINTER TO POINTER************
int **c = &ptr;
**c = 30;
cout<<"The value address of ptr is "<<&ptr<<endl;
cout<<"The value of **ptr at address ptr "<<**c<<endl;
return 0;
}