Originally Posted by
joanna_88
Hi met with an array question while studying , here it goes .
we declare: int x[4][3]; then x[i][j] is also said to be :
1)*(x[i] + j)
2)*(&x[0][0] + 4*i + j)
3)Both (a) and (b)
4)None of the above
actually i thing the answer shld be 1 or 4 .
If you have no real idea how the compiler handles these expression, why don't you try a little testprogram and let the compiler do the work for you :-)
Code:
#include <stdio.h>
int main ()
{
int x[4][3];
printf("%p -- %p\n", &x[2][1], &(*(x[2] + 1)));
return 0;
}
Though, answer 1) is correct!
- Andi -