-
Notifications
You must be signed in to change notification settings - Fork 1
/
heap.cpp
56 lines (42 loc) · 934 Bytes
/
heap.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
int main() {
int x = 20;
int *p;
p = malloc(4);
*p = 50;
printf("%d" , *p);
}
*****************************************************
int main() {
int x = 20;
int *p;
p = malloc(4);
*p = 50; //alloacation done
printf("%d\n" , *p);
free(p); //to dealocate the memory
printf("%d" , *p);
}
*****************************************************
int main() {
//stack memory
// complie time : 4 byte is confirmed
int x = 20;
printf("%d\n" , x);
x = NULL; //to dealocate the memory
printf("%d" , x);
}
*****************************************************
int main() {
// C++ heap memory
int x = 20;
p = new int ;
delete p;
}
*****************************************************
int main() {
//at complie time
// alloacation at runtime
//reversed memory
int b[5] = {};
b[2] = 20;
printf("%d" , b[2]);
}