sizeof()
Description
The sizeof operator returns the number of bytes in a variable type, or the number of bytes occupied by an array.
Syntax
sizeof(variable)
Parameter Values
Return Values
- The number of bytes in a variable or bytes occupied in an array. Data type: size_t.
Example Code
The sizeof operator is useful for dealing with arrays (such as strings) where it is convenient to be able to change the size of the array without breaking other parts of the program.
This program prints out a text string one character at a time. Try changing the text phrase.
※ NOTES AND WARNINGS:
Note that sizeof returns the total number of bytes. So for arrays of larger variable types such as ints, the for loop would look something like this.
Note that a properly formatted string ends with the NULL symbol, which has ASCII value 0.
See Also
- Language : PROGMEM
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |