Go Down

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

vinzenz82

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
}

maniacbug

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