Я делаю эксперимент по массивам и указателям:
int a[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int i = 1, j = 1;
int (*p)[3];
p = a;
printf ("*(*(a + i) + j) = %d\n", *(*(a + i) + j));
printf ("*(a[i] + j) = %d\n", *(a[i] + j));
printf ("*(a + i)[j] = %d\n", *(a + i)[j]);
printf ("*(a + 3 * i + j) = %p\n", *(a + 3 * i + j));
printf ("*(*(p + i) + j) = %d\n", *(*(p + i) + j));
printf ("*(p[i] + j) = %d\n", *(p[i] + j));
printf ("*(p + i)[j] = %d\n", *(p + i)[j]);
printf ("*(p + 3 * i + j) = %p\n", *(p + 3 * i + j));
printf ("p[i][j] = %d\n", p[i][j]);
Вывод:
1. *(*(a + i) + j) = 5
2. *(a[i] + j) = 5
3. *(a + i)[j] = 7
4. *(a + 3 * i + j) = 0x7fff5e0e5b94
5. *(*(p + i) + j) = 5
6. *(p[i] + j) = 5
7. *(p + i)[j] = 7
8. *(p + 3 * i + j) = 0x7fff5e0e5b94
9. p[i][j] = 5
Я понимаю вывод 1, 2, 4, 5, 6, 8 и 9. Но я не понимаю вывод 3 и 7.
Почему вывод 7
?