#include<stdio.h>
int main()
{
int arr[3][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
printf("%u ,%u\n",arr, &arr+1);
return 0;
}
In the print statement: (Assuming integer size 4 bytes)
Let arr's memory location be 1000
arr+1--gives 1016 (ie.next row memory)
1000 1004 1008 1012 1016
1 2 3 4 5
&arr+1 gives 1048
I understood the logic but I can't understand that how the compiler identifies
arr as 'pointer to an array of 4 integer' and
&arr as 'pointer to array of 3 arrays of 4 integer'
Even though both points to the same address (1000) before increment
arrdecays to the same type as&arr[0], which is an array of 4 integers.&arron the other hand is a pointer to array of 3 by 4 integers&arrgives you a pointer to the array.arrgives you a pointer to the array's first element.