So quick, odd question:
I took an exam, and a question was:
char c = 'A'
char *p =&c
char **p2 = &p
void *v = &p2
Write the type (i.e. int, void*, etc.) of the following expression:
&vp2 + 1v[0]
I answered:
void **char**- ILLEGAL
and lost full credit. I just wanted to get a second opinion from someone before I try to get points back.
-
I wasn’t too sure about, but I figured that, since
vwas avoidpointer to a memory address, the address ofvwould have been avoid**. Ifvwas dereferenced, however, it would be achar****. -
p2is achar**, so adding 1 to it would still make it achar**. -
v[0]doesn’t exist.
If someone could help me out with this kind of dumb problem, I’d be very grateful.
Thank you.
Your answers are correct, for the reasons you gave (apart for the bit about dereferencing
v, although it sounds like you already know that you can’t dereference avoid *).