-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut12.cpp
executable file
·29 lines (26 loc) · 1.11 KB
/
tut12.cpp
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
#include <iostream>
#include <iomanip>
int main() {
// pointers
int a = 3;
int* b = &a;
std::cout << "Value of a : " << std::setw(10) << a << std::endl;
std::cout << "Value of &a : " << std::setw(10) << &a << std::endl;
std::cout << "Value of b : " << std::setw(10) << b << std::endl;
std::cout << "Value of *b : " << std::setw(10) << *b << std::endl;
std::cout << std::endl;
// pointer-to-pointer
int x = 3;
int* y = &x;
int** z = &y;
std::cout << "Value of x : " << std::setw(10) << x << std::endl;
std::cout << "Value of &x : " << std::setw(10) << &x << std::endl;
std::cout << "Value of y : " << std::setw(10) << y << std::endl;
std::cout << "Value of *y : " << std::setw(10) << *y << std::endl;
std::cout << "Value of &y : " << std::setw(10) << &y << std::endl;
std::cout << "Value of z : " << std::setw(10) << z << std::endl;
std::cout << "Value of *z : " << std::setw(10) << *z << std::endl;
std::cout << "Value of **z : " << std::setw(10) << **z << std::endl;
std::cout << std::endl;
return 0;
}