-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex3.c
138 lines (104 loc) · 4.87 KB
/
ex3.c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <stdio.h>
int main(){
int a, b, c;
int * p1, * p2;
a=1; b=2; c=3;
printf("a\t b\t c\t &a\t\t\t &b\t\t &c\t\t p1\t\t p2\t\t *p1\t *p2\t \n"); // title of table
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t \n", (void*)&a, (void*)&b, (void*)&c);
//printf("%p\t %p\t \n", (void*)p1, (void*)p2);
//printf("%d\t %d\t \n", *p1, *p2);
p1=&a; p2=&c;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
*p1=*p2;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
(*p2)++;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p1=p2;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p2=&b;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p2=&c;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
*p1=a+b;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
a+=*p1;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
b=*p1+*p2;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
*p1=2*a;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
a=*p2;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p2=p1=&a;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p2++;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p1+=2;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" %d\t %d\t \n", *p1, *p2);
p1=NULL;
printf("%d\t %d\t %d\t ", a,b,c);
printf("%p\t %p\t %p\t ", (void*)&a, (void*)&b, (void*)&c);
printf(" %p\t %p\t", (void*)p1, (void*)p2);
printf(" ???\t %d\t \n", *p2);
return 0;
}
// a b c &a &b &c p1 p2 *p1 *p2
// 1 2 3 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c
// 1 2 3 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c564 0x7fff57f0c56c 1 3
// 3 2 3 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c564 0x7fff57f0c56c 3 3
// 3 2 4 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c564 0x7fff57f0c56c 3 4
// 3 2 4 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 4 4
// 3 2 4 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c568 4 2
// 3 2 4 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 4 4
// 3 2 5 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 5 5
// 8 2 5 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 5 5
// 8 10 5 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 5 5
// 8 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 16 16
// 16 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c56c 16 16
// 16 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c564 0x7fff57f0c564 16 16
// 16 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c564 0x7fff57f0c568 16 10
// 16 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c 0x7fff57f0c56c 0x7fff57f0c568 16 10
// 16 10 16 0x7fff57f0c564 0x7fff57f0c568 0x7fff57f0c56c (nil) 0x7fff57f0c568 ??? 10