What is the output of this C code?
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}
Answer: B
Correct answer: Compile time error
p is an int *, so &p has type int **, and initialising an int * from it is a constraint violation - the levels of indirection do not match. The declaration should read int **r = &p;, which is exactly what the following question does. Some compilers downgrade this to a warning, but it is an error in standard C.
Please log in or register to report this question.