What is the output of this C code?
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
Answer: A
Correct answer: 5 5 5
Each dereference removes one level. k is 5; p holds the address of k, so *p is 5; and m holds the address of p, so *m is p and **m is 5. All three names reach the same object by paths of different length, which is the whole point of the double pointer.
Please log in or register to report this question.