Search wiring.org.co:

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name |

### sizeof()

Examples |
    char arr[10]; // Array of 10 characters
    int val = 1000;

    void setup()
    {
      Serial.begin(9600);
      Serial.print("Array size in bytes is: ");
      Serial.println(sizeof(arr));
      Serial.print("val size in bytes is: ");
      Serial.println(sizeof(val));
      Serial.print("double datatype size in bytes is: ");
      Serial.println(sizeof(double));
    }

    void loop()
    {

    }
Description | The sizeof operator is used to determine the amount of space in bytes any data-element/datatype occupies in memory. To use sizeof, the keyword "sizeof" is followed by a type name, variable, or expression. If a type name is used, it always needs to be enclosed in parentheses, whereas variable names and expressions can be specified with or without parentheses.
Syntax |
    sizeof var
    sizeof(var)
    sizeof(datatype)
Parameters |

var | variable name
datatype | any valid datatype: int, double, float, char, double

Returns | int: the size in bytes
Usage | Application

Updated on July 07, 2011 11:09:00pm PDT