aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/lang/sizeof.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-12-03 20:18:00 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-12-03 20:18:00 -0500
commit5ceac644e90c929e77f05d357d1d35d45e673fac (patch)
tree18c76f6117942fa46391fbbd8bd24e2c759c4895 /docs/source/lang/sizeof.rst
parente5b1e44a8ae8c593456f4b4734f05c9065f6f07b (diff)
downloadlibrambutan-5ceac644e90c929e77f05d357d1d35d45e673fac.tar.gz
librambutan-5ceac644e90c929e77f05d357d1d35d45e673fac.zip
cleaning up previous commits.
note that addition of new files under docs/source/lang/api and docs/source/lang/cpp which were just copies of files in docs/source/lang/ imply that change history is lost to git.
Diffstat (limited to 'docs/source/lang/sizeof.rst')
-rw-r--r--docs/source/lang/sizeof.rst64
1 files changed, 0 insertions, 64 deletions
diff --git a/docs/source/lang/sizeof.rst b/docs/source/lang/sizeof.rst
deleted file mode 100644
index eae509c..0000000
--- a/docs/source/lang/sizeof.rst
+++ /dev/null
@@ -1,64 +0,0 @@
-.. highlight:: cpp
-
-.. _lang-sizeof:
-
-``sizeof()``
-============
-
-The ``sizeof`` operator on the Maple returns the number of bytes
-needed to store a value of a given type\ [#fcharsize]_. This can be
-an ordinary numeric type, like ``int``. It can be something more
-complicated, like a ``struct`` or ``union``. If the argument to
-``sizeof`` is an array, it returns the total number of bytes occupied
-by the array.
-
-The general syntax looks like this::
-
- sizeof(type)
- sizeof(var)
-
-Example
--------
-
-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 ``int``, the :ref:`for loop <lang-for>`
-would look something like this::
-
- for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) {
- // do something with myInts[i]
- }
-
-.. rubric:: Footnotes
-
-.. [#fcharsize] Technically (and pedantically) speaking, ``sizeof``
- returns a multiple of the number of bits a ``char`` occupies in
- memory. However, on the Maple (this goes for most C++
- implementations), a ``char`` occupies 8 bits = 1 byte. All the C++
- standard guarantees, however, is that a ``char`` occupies at
- *least* 8 bits.
-
-.. include:: cc-attribution.txt
-