Go Down

Topic: Small mistake in reference about SizeOff (Read 900 times) previous topic - next topic

To whom it may concern:

http://arduino.cc/en/Reference/Sizeof

the last example:

for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) {
  // do something with myInts
}

will never use the last elem of myInts

should be:

for (i = 0; i < (sizeof(myInts)/sizeof(int)); i++) {
  // do something with myInts
}

Although in the case of processing strings (as used on that page), skipping the final entry is usually preferred because it's a 0.  That said, the example could definitely be tweaked to be more informative to a beginner by NOT using a string in the example.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy