I'm diving into C again after a number of years. I thought that the following two print statements would have evaluated to the same output, based on other answers I have found; however it does not appear to be the case.
int main()
{
int** arr = malloc(
3 * sizeof(int*)
);
for(int y = 0; y < 3; y++) {
int* subarr = malloc(
3 * sizeof(int)
);
for(int x = 0; x < 3; x++) {
subarr[x] = y * 3 + x + 1;
}
arr[y] = subarr;
}
printf("%d\n", *(&arr[0][0]) + 3);
printf("%d\n", (&arr[0][0])[3]);
}
Could anyone explain what is going on here/what I am missing?