-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25_doublepointers.cpp
More file actions
24 lines (19 loc) · 829 Bytes
/
Copy path25_doublepointers.cpp
File metadata and controls
24 lines (19 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
int main(){
// Double pointers are the pointers which stores the address of the pointer
int num = 9;
int* ptr = # // single pointer
int** dptr = &ptr; //double pointer: storing address of single pointer
// printing the address stored by the pointers
cout<<"Address of num: "<<&num<<endl;
cout<<"Address stored by the single pointer ptr: "<<ptr<<endl<<endl;
cout<<"Address of single pointer is: "<<&ptr<<endl;
cout<<"Address stored by the double pointer dptr: "<<dptr<<endl;
// accessing the value of num from single and double pointers
cout<<endl;
cout<<"Num is: "<<num<<endl;
cout<<"Num from single pointer is: "<<*ptr<<endl;
cout<<"Num from double pointer is: "<<**dptr<<endl;
return 0;
}