- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimple_Pointer_Program.cpp
More file actions
Latest commit
43 lines (23 loc) · 597 Bytes
/
Copy pathSimple_Pointer_Program.cpp
File metadata and controls
43 lines (23 loc) · 597 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdio.h>
// Basic Pointer Program
intmain(){
// Variable
int a = 10;
// Pointer b has address of variable a
int *b = &a;
// Double Pointer c has address of variable b which is then can access address of variable a
int **c = &b;
// Print each variable address
printf ("%d\n", &a);
printf ("%d\n", &b);
printf ("%d\n", &c);
// a = 10
printf ("%d\n", a);
a = 15;
// *b will be 15 because the value of a change to 15
printf ("%d\n", *b);
a = 20;
// **c will be 20 because the value of a change to 20
printf ("%d\n", **c);
return0;
}