This repository was archived by the owner on Aug 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer4.c
More file actions
69 lines (62 loc) · 1.28 KB
/
pointer4.c
File metadata and controls
69 lines (62 loc) · 1.28 KB
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
#include <stdio.h>
int main() {
int a[3][4] = { 10, 20, 30, 40, 50 };
int (*ptr)[4]; //2Â÷¿ø ¹è¿°ú Æ÷ÀÎÅÍ
ptr = a;
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 4; j++)
{
printf("%2d %p ", ptr[i][j], &a[i][j]);
}
printf("\n");
}
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 4; j++)
{
printf("%2d %p ", *(*(ptr + i) + j), *(ptr + i) + j);
}
printf("\n");
}
return 0;
}
/*#include <stdio.h>
int main() {
int num[3] = { 10,20,30 };
int *ptr[3];
for (int i = 0; i < 3; i++)
{
ptr[i] = num + i;
}
for (int i = 0; i < 3; i++)
{
printf("%p %p %p %p\n", ptr[i], &num[i], *(ptr + i), num + i);
}
for (int i = 0; i < 3; i++)
{
printf("%d %d %d %d\n", *ptr[i], num[i], *(*(ptr + i)), *(num + i));
}
}*/
/*#include <stdio.h>
int main() {
char a[10] = "hello";
char *p = "hello";
printf("%s %p\n", a, a);
printf("%c %p\n", a[1], &a[1]);
printf("%s %p\n", p, p);
printf("%c %p\n", *(p + 1), p + 1);
}*/
/*#include <stdio.h>
int main() {
char name[4][15] = { "apple", "peach", "grape", "watermelon" };
char *ptr[4] = { "apple", "peach", "grape", "watermelon" };
for (int i = 0; i < 4; i++)
{
printf("%p %s %c\n", name[i], name[i], name[i][0]);
}
for (int i = 0; i < 4; i++)
{
printf("%p %s %c\n", ptr[i], ptr[i], *ptr[i]);
}
}*/