Dear Webmaster,
I think it might be necessary a correction in the example written in web page http://arduino.cc/en/Reference/Array,
section "Creating (Declaring) an Array":
wrong text:
int myInts[6];
int myPins[] = {2, 4, 8, 3, 6};
int mySensVals[6] = {2, 4, -8, 3, 2};
proper text:
int myInts[5];
int myPins[] = {2, 4, 8, 3, 6};
int mySensVals[5] = {2, 4, -8, 3, 2};
I suggested the correction here because "Corrections, suggestions, and new documentation should be posted to the Forum".
No, this is correct C although I agree it not "clean code"
int mySensVals[6] = {2, 4, -8, 3, 2};
initializes the first 5 elements of the array of size 6.
Most compilers will initialize the 6th element with zero iff the arra is declared global.
Check this code.
int mySensVals[6] = {2, 4, -8, 3, 2};
void setup()
{
Serial.begin(115200);
Serial.println("Start ");
for (int i=0; i<6; i++)
{
Serial.println(mySensVals[i]);
}
}
void loop()
{
}
That said, I agree it is not a clean example.
Why do you think that
int myInts[6];
should be
int myInts[5];
As this variable is not referenced anywhere there could be any number in the braces.
Besides which we have bee trying to get the real error of the capacitor on the latch pin in the shift out tutorial, fixed for over 6 years and that is a real error that can cause real harm.