In KR C book page 112 it says that following:
int (*arr1)[10];
is a pointer to an array of 10 integers. I don't get what's difference between above and:
int arr2[10];
1- Isn't arr2 itself a pointer to array of 10 integers? (Because name of an array is a pointer itself.)
2- If the name of an array is the array address and pointer to that array, then both arr1 and arr2 are pointer to array of integers, isn't this true?
No, it's an array.
Array names can be/are converted to pointers to their 0th element (not the entire array).
No.
arr1is a pointer to an array of 10 integers.arr2is an array of 10 integers. In most contexts it converts to a pointer to an integer (not a pointer to an array).Check this wrong example for instance:
Here I am treating both
arr1andarr2as the "same thing", and I got this error:But if I do:
it will pass compilation! Same with
(*arr1)[5] = 747;of course.