[CSI] negative indexes
Mikhail Nesterenko
mikhail at cs.kent.edu
Tue Aug 8 10:01:40 EDT 2017
CSI students,
There was a question last time whether negative indexes are allowed in
the array. That is, if this
a[-5]
is legal. Indeed it is legal. However, negative index still needs to
point to a valid element of the array.
In general, indexing operation a[i] is equivalent to *(a+i) in pointer
arithmetic.
Hence, a[-5] is equivalent to *(a-5).
Thanks,
--
Mikhail
More information about the cs13001
mailing list