Abstract
- An array name is a fixed pointer; it points to the first element of the array and thus cannot be altered,
source
is same as&source[0]
. The code above attempts to alterdest
, making it point elsewhere
What if I want to make a copy to another array?
Use a for-loop,
for (int i=0; i<N; i++) dest[i] = source[i];
.
Important
Using the code snippet example above,
source[2]
represents the value30
itself, not a pointer or reference to the value30
.