-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpointer.cpp
More file actions
28 lines (27 loc) · 957 Bytes
/
pointer.cpp
File metadata and controls
28 lines (27 loc) · 957 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
25
26
27
28
#include <iostream>
int main()
{
int A = 100;
int *B = &A;
std::cout << "A = " << A << std::endl;
std::cout << "The address of A is:" << &A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "The value of B is:" << *B << std::endl;
A = 200;
std::cout << "A = " << A << std::endl;
std::cout << "The address of A is:" << &A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "The value of B is:" << *B << std::endl;
*B = 300;
std::cout << "A = " << A << std::endl;
std::cout << "The address of A is:" << &A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "The value of B is:" << *B << std::endl;
B = new int;
*B = 400;
std::cout << "A = " << A << std::endl;
std::cout << "The address of A is:" << &A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "The value of B is:" << *B << std::endl;
return 0;
}