C data types

They are expressed in the language syntax in form of declarations for memory locations or variables.

Headers for the C standard library, to be used via include directives, contain definitions of support types, that have additional properties, such as providing storage with an exact size, independent of the language implementation on specific hardware platforms.

The following table lists the permissible combinations in specifying a large set of storage size-specific declarations.

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.

[10][11] Various rules in the C standard make unsigned char the basic type used for arrays suitable to store arbitrary non-bit-field objects: its lack of padding bits and trap representations, the definition of object representation,[7] and the possibility of aliasing.

Additionally, the header defines bool as a convenient alias for this type, and also provides macros for true and false.

_Bool functions similarly to a normal integer type, with one exception: any assignments to a _Bool that are not 0 (false) are stored as 1 (true).

This behavior exists to avoid integer overflows in implicit narrowing conversions.

For example, in the following code: In C23, the boolean type was moved to bool, making the header now useless.

However, changing the type causes the previous code to behave normally: The type _Bool also ensures true values always compare equal to each other: In C23, bool became a core functionality of the language, allowing for the following examples of code: Since C23, the language allows the programmer to define integers that have a width of an arbitrary number of bits.

size_t is an unsigned integer type used to represent the size of any object (including arrays) in the particular implementation.

The C99 standard includes definitions of several new integer types to enhance the portability of programs.

[2] The already available basic integer types were deemed insufficient, because their actual sizes are implementation defined and may vary across different systems.

Here {fmt} defines the output formatting and is one of d (decimal), x (hexadecimal), o (octal), u (unsigned) and i (integer).

Here {fmt} defines the output formatting and is one of d (decimal), x (hexadecimal), o (octal), u (unsigned) and i (integer).

The structure definition is followed by a declaration of the variable John that allocates the needed storage.

The latter are less common than an array of pointers, and their syntax may be confusing: The element pc requires ten blocks of memory of the size of pointer to char (usually 40 or 80 bytes on common platforms), but element pa is only one pointer (size 4 or 8 bytes), and the data it refers to is an array of ten bytes (sizeof *pa == 10).

Of these, const is by far the best-known and most used, appearing in the standard library and encountered in any significant use of the C language, which must satisfy const-correctness.