-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpointer_to_pointer.cpp
More file actions
46 lines (33 loc) · 1.29 KB
/
Copy pathpointer_to_pointer.cpp
File metadata and controls
46 lines (33 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using namespace std;
int main(){
int value = 100;
int *pointer_1;
pointer_1 = &value;
int **pointer_2;
pointer_2 = &pointer_1;
int ***pointer_3;
pointer_3 = &pointer_2;
//-----------> output
cout << pointer_1 << endl; // output : 0x61ff08
cout << *pointer_1 << endl;// output : 100
cout << *pointer_2 + 1 << endl;// output : 0x61ff0c
cout << **pointer_2 << endl;// output : 100
cout << **pointer_2 + 100 << endl;// output : 200
cout << **pointer_3 << endl;// output : 0x61ff08
cout << ***pointer_3 << endl;// output : 100
cout << endl << endl << endl;
***pointer_3 = 3000;
cout << "***pointer_3 = 3000" << endl;// output : ***pointer_3 = 3000
cout << "value = " << ***pointer_3 << endl;// output : value = 3000
cout << endl << endl << endl;
**pointer_2 = *pointer_1 + 100;
cout << "**pointer_2 = *pointer_1 + 100; = " << **pointer_2 << endl;
// output : **pointer_2 = *pointer_1 + 100; = 3100
cout << endl << endl ;
cout <<"pointer_1 = "<< *pointer_1 << endl;// output :pointer_1 = 3100
cout <<"pointer_2 = "<< **pointer_2 << endl;// output : pointer_2 = 3100
cout <<"pointer_3 = "<< ***pointer_3 << endl;// output : pointer_3 = 3100
cout << "value = " << value << endl;// output : value = 3100
return 0;
}