1 #include <stdio.h>
2
3 int main()
4 {
5 int valArr[3] = {1, 2, 3};
6 int *ptrArr[3] = {NULL};
7 int *ptr = NULL;
8 int **pptr = NULL;
9
10 ptrArr[0] = &valArr[0];
11 ptrArr[1] = &valArr[1];
12 ptrArr[2] = &valArr[2];
13
14 ptr = &valArr[0];
15 pptr = (int **)&ptr;
16
17 printf("ptrArr = %x/n", ptrArr);
18 printf("&ptrArr = %x/n", &ptrArr);
19 printf("ptrArr[0] = %x/n", ptrArr[0]);
20 printf("&ptrArr[0] = %x/n", &ptrArr[0]);
21 printf("ptr = %x/n", ptr);
22 printf("pptr = %x/n", pptr);
23 printf("pptr[0] = %x/n", pptr[0]);
24 }
~/testbench> gcc -o testPtrArr testPtrArr.c
~/testbench> ./testPtrArr
ptrArr = bfc67048
&ptrArr = bfc67048
ptrArr[0] = bfc67054
&ptrArr[0] = bfc67048
ptr = bfc67054
pptr = bfc67044
pptr[0] = bfc67054
2
3 int main()
4 {
5 int valArr[3] = {1, 2, 3};
6 int *ptrArr[3] = {NULL};
7 int *ptr = NULL;
8 int **pptr = NULL;
9
10 ptrArr[0] = &valArr[0];
11 ptrArr[1] = &valArr[1];
12 ptrArr[2] = &valArr[2];
13
14 ptr = &valArr[0];
15 pptr = (int **)&ptr;
16
17 printf("ptrArr = %x/n", ptrArr);
18 printf("&ptrArr = %x/n", &ptrArr);
19 printf("ptrArr[0] = %x/n", ptrArr[0]);
20 printf("&ptrArr[0] = %x/n", &ptrArr[0]);
21 printf("ptr = %x/n", ptr);
22 printf("pptr = %x/n", pptr);
23 printf("pptr[0] = %x/n", pptr[0]);
24 }
~/testbench> gcc -o testPtrArr testPtrArr.c
~/testbench> ./testPtrArr
ptrArr = bfc67048
&ptrArr = bfc67048
ptrArr[0] = bfc67054
&ptrArr[0] = bfc67048
ptr = bfc67054
pptr = bfc67044
pptr[0] = bfc67054