I read this in my book (and many sources on the internet):
The array variable points to the first element in the array.
When you use an array expression, the compiler converts it to a pointer to the first element. This is an explicit conversion specified by the 1999 C standard, in 6.3.2.1 3. It is a convenience for you, so that you do not have to write &array[0]
to get a pointer to the first element.
The conversion happens in all expressions except when an array expression is the operand of sizeof
or the unary &
or is a string literal used to initialize an array.
You can see that an array and its first element are different by printing sizeof array
and sizeof array[0]
.