Here's how it really works, see the code and comments:
#include <stdio.h>
int x[3][5] =
{
{ 1, 2, 3, 4, 5 },
{ 6, 7, 8, 9, 10 },
{ 11, 12, 13, 14, 15 }
};
int (*pArr35)[3][5] = &x;
// &x is a pointer to an array of 3 arrays of 5 ints.
int (*pArr5a)[5] = x;
// x decays from an array of arrays of 5 ints to
// a pointer to an array of 5 ints,
// x is a pointer to an array of 5 ints.
int (*pArr5b)[5] = &x[0];
// &x[0] is a pointer to 0th element of x,
// x[0] is an array of 5 ints,
// &x[0] is a pointer to an array of 5 ints.
int *pInta = x[0];
// x[0] is 0th element of x,
// x[0] is an array of 5 ints,
// x[0] decays from an array of 5 ints to
// a pointer to an int.
int *pIntb = *x;
// x decays from an array of arrays of 5 ints to
// a pointer to an array of 5 ints,
// x is a pointer to an array of 5 ints,
// *x is an array of 5 ints,
// *x decays from an array of 5 ints to
// a pointer to an int.
int *pIntc = &x[0][0];
// x[0][0] is 0th element of x[0],
// where x[0] is an array of 5 ints,
// x[0][0] is an int,
// &x[0][0] is a pointer to an int.
int main(void)
{
printf("&x=%p x=%p &x[0]=%p x[0]=%p *x=%p &x[0][0]=%p\n",
pArr35, pArr5a, pArr5b, pInta, pIntb, pIntc);
return 0;
}
Sample output:
&x=0040805c x=0040805c &x[0]=0040805c x[0]=0040805c *x=0040805c &x[0][0]=0040805c
All the resultant pointers are the same value-wise because I used explicitly or implicitly indices of 0 and because arrays are contiguous and their very first (IOW, 0th) element is always at the lowest address in the array. So, even though there are 3 different pointer types, all effectively point at x[0][0], at the element that's equal 1.
This decaying of arrays to pointers is a very important feature of C and C++, although it's hard to grasp immediately.
It lets us write more compact code when passing pointers to arrays, we can just write the array's name instead of taking the address of its first element:
char str1[] = { 's', 't', 'r', '1', '\0' };
char str2[] = "str2";
printf("%s %s %s %s\n", &str1[0], str1, &str2[0], str2);
Output:
str1 str1 str2 str2
It also lets us do crazy things:
int y[3] = { 10, 20, 30 };
printf("%d %d %d %d\n", y[2], *(y+2), *(2+y), 2[y]);
Output:
30 30 30 30
All because a[b]
is equivalent to *(a+b)
when it comes to arrays and pointers.