The problem is that your function doesn't receive an array value; it receives a pointer value.
Except when it is the operand of the sizeof
or unary &
operators, or it is a string literal being used to initialize another array in a declaration, an expression of type "array of T
" will be converted to type "pointer to T
" and its value will be the address of the first element of the array.
Thus, when you call printarray
, the type of array1
is implicitly converted from "100-element array of double
" to "pointer to double
." Thus, the type of the parameter p
is double *
, not double [100]
.
In the context of a function parameter declaration, T a[]
is identical to T *a
.
This is why you have to pass the array size separately;