Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
sizeof
◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Keyword: sizeof
Syntax: sizeof expression
Summary: Gives the amount of storage, in bytes, associated with a
variable or a type (including aggregate types).
The <expression> is either an identifier or a type-cast expression
(a type specifier enclosed in parentheses).
When applied to a structure type or variable, sizeof returns the
actual size, which may include padding bytes inserted for
alignment. When applied to an array identifier, sizeof returns the
size of the entire array. When applied to a string constant or
variable, sizeof returns the entire size, including the
terminating zero. For example,
int *buf = calloc( 100, sizeof( int ) ); // sizeof( int ) is 2
char *str = "1234567890" // sizeof str is 11
struct POS // sizeof( struct POS )
{ // may not be two
char row; // because of alignment
char col;
};
int array[] = { 1, 2, 3, 4, 5 }; // sizeof array is 10
// sizeof array[0] is 2
int sizearr = // Count of items in array
sizeof( array) / sizeof( array[0] );
-♦-