diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-21 10:27:37 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-21 10:27:37 -0500 |
commit | c45bccad44187da27505cf5808424e709e3f54a1 (patch) | |
tree | 18a459a50f8d0551ba046e30462c93999d982725 /docs/source/arduino/sizeof.rst | |
parent | 84fd2532a7f23d20354ff590790b3f892cb7e7d7 (diff) | |
parent | d5ad2a27f4e69e6cc9324331945937c983c30366 (diff) | |
download | librambutan-c45bccad44187da27505cf5808424e709e3f54a1.tar.gz librambutan-c45bccad44187da27505cf5808424e709e3f54a1.zip |
Merge branch 'master' into debug-serialusb.
Chose debug-serialusb version in cases of conflict.
Conflicts:
libmaple/usb/usb_callbacks.c
Diffstat (limited to 'docs/source/arduino/sizeof.rst')
-rw-r--r-- | docs/source/arduino/sizeof.rst | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/docs/source/arduino/sizeof.rst b/docs/source/arduino/sizeof.rst deleted file mode 100644 index a95dfbf..0000000 --- a/docs/source/arduino/sizeof.rst +++ /dev/null @@ -1,71 +0,0 @@ -.. _arduino-sizeof: - -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) - - - -Parameters ----------- - -variable: any variable type or array (e.g. int, float, byte) - - - -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. - - - -:: - - char myStr[] = "this is a test"; - int i; - - void setup(){ - Serial.begin(9600); - } - - void loop() { - for (i = 0; i < sizeof(myStr) - 1; i++){ - Serial.print(i, DEC); - Serial.print(" = "); - Serial.println(myStr[i], BYTE); - } - } - - -Note that sizeof returns the total number of bytes. So for larger -variable types such as ints, the for loop would look something like -this. - - - -:: - - for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) { - // do something with myInts[i] - } - |