Pointers and Arrays
For the declaration: double weight[LEN], *pw; the following holds:
weight[i] is an expression of type double that refers to the value stored in the (i+1)th entry of the array
weight is an expression of type pointer to double that refers to the address of the first element of the array.- This means that weight==&(weight[0]) is always TRUE.
Fact: The C compiler always translates an “array expression” like weight[i] into the equivalent “pointer expression” *(weight+i)
After assigning pw = weight, the expressionpw[2] has the value weight[2]
The main difference between pw and weight: weight is constant (cannot be assigned to) and pw is a variable !