L
lovecreatesbeauty
Why (type*)pointer isn't equal to *(type**)pointer,
In the code snippet, it shows that:
(int *) == (int **) ,
(int *) != (*(int **)) .
Does type-casting change the address? or doesn't type-casting do
anything?
1 int main(void)
2 {
3 char ch;
4 int *p;
5 int *p2;
6 int *p3;
7
8 ch = 'c';
9 p = (int *)(&ch);
10 p2 = *(int **)(&ch);
11 p3 = (int **)(&ch);
12
13 printf("%c", *p);
14 printf("%c", *p2); /* error in de-reference */
15 printf("%c", *p3);
16
17 return 0;
18 }
19
~
~
Thank you
lovecreatesbeauty
In the code snippet, it shows that:
(int *) == (int **) ,
(int *) != (*(int **)) .
Does type-casting change the address? or doesn't type-casting do
anything?
1 int main(void)
2 {
3 char ch;
4 int *p;
5 int *p2;
6 int *p3;
7
8 ch = 'c';
9 p = (int *)(&ch);
10 p2 = *(int **)(&ch);
11 p3 = (int **)(&ch);
12
13 printf("%c", *p);
14 printf("%c", *p2); /* error in de-reference */
15 printf("%c", *p3);
16
17 return 0;
18 }
19
~
~
Thank you
lovecreatesbeauty