sizeof

Syntax

int sizeof( type )

Arguments

type
The name of a built-in C language data type

Return

Returns the number of bytes required to store a variable of the given data type.

Description

Gives the number of bytes needed to store a variable of the given data type. This is useful when the size of a data type might vary on different computers (eg a 64-bit int requires more bytes than a 32-bit int).

Example

printf("Size of an int: %d bytes\nSize of a float: %d bytes\nSize of a char: %d bytes", sizeof(int), sizeof(float), sizeof(char));