In the C programming language, data types are declarations for memory locations or variables that determine the characteristics of the data that may be stored and the methods (operations) of processing that are permitted involving them.
The C language provides basic arithmetic types, such as integer and real number types, and syntax to build array and compound types. Several headers in the C standard library contain definitions of support types, that have additional properties, such as providing storage with an exact size, independent of the implementation.
The C language provides the four basic arithmetic type specifiers char, int, float and double, and the modifiers signed, unsigned, short and long. The following table lists the permissible combinations to specify a large set of storage size-specific declarations.
(%lf (%lF) for scanf()
)
%g %G
%e %E (for scientific notation)
The actual size of integer types varies by implementation. The standard only requires size relations between the data types and minimum sizes for each data type:
The relation requirements are that the long long
is not smaller than long
, which is not smaller than int
, which is not smaller than short
. As char
's size is always the minimum supported data type, no other data types (except bit-fields) can be smaller.
The minimum size for char
is 8 bits, the minimum size for short
and int
is 16 bits, for long
it is 32 bits and long long
must contain at least 64 bits.
The type int
should be the integer type that the target processor is most efficiently working with. This allows great flexibility: for example, all types can be 64-bit. However, several different integer width schemes (data models) are popular. This is because the data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.
In practice, char
is usually eight bits in size and short
is usually 16 bits in size (as are their unsigned counterparts). This holds true for platforms as diverse as 1990s SunOS 4 Unix, Microsoft MS-DOS, modern Linux, and Microchip MCC18 for embedded 8-bit PIC microcontrollers. POSIX requires char
to be exactly eight bits in size.