Here I have a pointer ptr to array arr of 4 integers. ptr points to the whole array. ptr[0] or *ptr points to the first element of the array, so adding 1 to ptr[0] gives the address of the second element of the array.
I can't understand why using sizeof(ptr[0]) gives the size of the whole array, 16 bytes, not the size of only the first element, 4 bytes, (as ptr[0] points to the first element in the array).
int arr[4] = {0, 1, 2, 3};
int (*ptr)[4] = &arr;
printf("%zd", sizeof(ptr[0])); //output is 16
int *ptr = arr;? That would make it point to the start (first element of) the array, which is equivalent to&arr[0].int *ptr = arr;? Actually, no.int (*ptr)[4]createsptras a pointer to a full array of fourintvalues. Pointer syntax like that is necessary to dynamically allocate true-multidimensional arrays. The "2-dimensional arrays" created with nestedmalloc()loops and wrongly described as multidimensional arrays are really 1-d arrays of pointers to multiple 1-d arrays. See stackoverflow.com/questions/42094465/…