In C, I have:
char *p, *q;
p = malloc(1); //for the purpose testing only
p[0] = '!';
q = *((char **)p);
printf("p=%x q=%x\n", p, q);
printf("p=%c q=%c\n", p, q);
There were no casting warnings, and the output is:
p=1a9008 q=21
p q=!
What happens in the expression assigned to q
, ie *((char **)p)
? Has the type of q
changed after the assignment?
Edits: there is an error in my code. While trying to distil it from a code fragment I came across into a fully working example, I wrongly used an example value of type char for p. After examining more of the original code, p was assigned a pointer value. So p is a pointer to a pointer.