Original question: If I define:
const int z[5] = {10, 11, 12, 13, 14};
does it mean:
- it's a constant array of integers i.e. the address which z points to is always constant and can never change, but the elements of z can change.
OR
- Each element of z is a constant i.e. their value can never change.
Edit:
More info:
There is another variable:
const int *y = z;
func((int *) y);
where func is defined as:
void func(int y[]) {
int i;
for(i = 0; i < 5; i++) {
y[i] = i; //y[i] can be set to any integer; used i as example
}
}
where in func, using y, the array is traversed and each element is changed. Is this is valid even though all elements of z are const?