As the variable t
is declared as having an array type
int t[3];
then sizeof( t )
yields a value equal to 3 * sizeof( int )
The C Standard (6.5.3.4 The sizeof and alignof operators)
2 The sizeof operator yields the size (in bytes) of its operand,
and indeed an array with three elements of type int
occupies memory equal in bytes to 3 * sizeof( int )
.
In expressions with rare exceptions as using in the sizeof
operator array designators are converted to pointers to their first elements.
Thus if you will use for example the following expression
sizeof( t + 0 )
then t
in the expression t + 0
will be converted to pointer and you will get that sizeof( t + 0 )
is equal to the size of a pointer to int
on your platform, which is 8
.
From the C Standard (6.3.2.1 Lvalues, arrays, and function designators)
3 Except when it is the operand of the sizeof operator or the unary &
operator, or is a string literal used to initialize an array, an
expression that has type ‘‘array of type’’ is converted to an
expression with type ‘‘pointer to type’’ that points to the initial
element of the array object and is not an lvalue. If the array object
has register storage class, the behavior is undefined.