C data types#stddef.h
{{Short description|Data types supported by the C programming language}}
{{Use dmy dates|date=July 2021}}
{{C Standard Library}}
In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables. Data types also determine the types of operations or methods of processing of data elements.
The C language provides basic arithmetic types, such as integer and real number types, and syntax to build array and compound types. 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.{{cite web|url=https://barrgroup.com/Embedded-Systems/How-To/C-Fixed-Width-Integers-C99|title=Portable Fixed-Width Integers in C|last=Barr|first=Michael|date=2 December 2007|access-date=18 January 2016}}{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | title=ISO/IEC 9899:1999 specification, TC3 | at=p. 255, § 7.18 Integer types
Primary types
=Main types=
The C language provides the four basic arithmetic type specifiers {{mono|char}}, {{mono|int}}, {{mono|float}} and {{mono|double}} (as well as the boolean type {{mono|bool}}), and the modifiers {{mono|signed}}, {{mono|unsigned}}, {{mono|short}}, and {{mono|long}}. The following table lists the permissible combinations in specifying a large set of storage size-specific declarations.
class="wikitable" | |||||
Type
! Explanation ! Size (bits) ! Format specifier ! Range ! Suffix for decimal constants | |||||
---|---|---|---|---|---|
{{mono|bool}} | Boolean type, added in C23. | 1 (exact) | %d | {{bracket|{{mono|false}}, {{mono|true}}}} | {{n/a}} |
{{mono|char}} | Smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned. It contains CHAR_BIT bits. | ≥8 | %c | {{bracket|{{mono|CHAR_MIN}}, {{mono|CHAR_MAX}}}} | {{n/a}} |
{{mono|signed char}} | Of the same size as char, but guaranteed to be signed. Capable of containing at least the {{closed-closed|size=100%|−127, +127}} range.{{efn|name=restr|1=The minimal ranges {{closed-closed|size=100%|−(2n−1−1), 2n−1−1}} (e.g. [−127,127]) come from the various integer representations allowed by the standard (ones' complement, sign-magnitude, two's complement).{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf | title=Rationale for International Standard—Programming Languages—C Revision 5.10 | at=p. 25, § 5.2.4.2.1 Sizes of integer types SCHAR_MIN == −128 and SCHAR_MAX == 127 ) for an 8-bit signed char. Since C23, the only representation allowed is two's complement, therefore the values range from at least {{closed-closed|size=100%|−2n−1, 2n−1−1}}.{{cite book | url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3096.pdf| title=ISO/IEC 9899:2023 specification draft| at=p. 41, § 6.2.6 Representations of types}}}} | ≥8 | %c {{efn|or %hhi for numerical output}} | {{bracket|{{mono|SCHAR_MIN}}, {{mono|SCHAR_MAX}}}}{{cite web |url=https://docs.microsoft.com/en-us/cpp/c-language/cpp-integer-limits?view=msvc-170| title=C and C++ Integer Limits | date=21 July 2023 }} | {{n/a}} |
{{mono|unsigned char}} | Of the same size as char, but guaranteed to be unsigned. Contains at least the {{closed-closed|size=100%|0, 255}} range.{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | title=ISO/IEC 9899:1999 specification, TC3 | at=p. 37, § 6.2.6.1 Representations of types – General}} | ≥8 | %c {{efn|or %hhu for numerical output}} | {{bracket|0, {{mono|UCHAR_MAX}}}} | {{n/a}} |
{{Plainlist|
}} | Short signed integer type. Capable of containing at least the {{closed-closed|size=100%|{{val|−32767}}, {{val|+32767}}}} range.{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | title=ISO/IEC 9899:1999 specification, TC3 | at=p. 22, § 5.2.4.2.1 Sizes of integer types | ≥16 | %hi or %hd | {{bracket|{{mono|SHRT_MIN}}, {{mono|SHRT_MAX}}}} | {{n/a}} | |
{{Plainlist|
}} | Short unsigned integer type. Contains at least the {{closed-closed|size=100%|{{val|0}}, {{val|65535}}}} range. | ≥16 | %hu | {{bracket|0, {{mono|USHRT_MAX}}}} | {{n/a}} | |
{{Plainlist|
}} | Basic signed integer type. Capable of containing at least the {{closed-closed|size=100%|{{val|−32767}}, {{val|+32767}}}} range.{{efn|name=restr}} | ≥16 | %i or %d | {{bracket|{{mono|INT_MIN}}, {{mono|INT_MAX}}}} | {{CNone|none{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | title=ISO/IEC 9899:1999 specification, TC3 | at=p. 56, § 6.4.4.1 Integer constants}}}} | |
{{Plainlist|
}} | Basic unsigned integer type. Contains at least the {{closed-closed|size=100%|{{val|0}}, {{val|65535}}}} range. | ≥16 | %u | {{bracket|0, {{mono|UINT_MAX}}}} | {{mono|u}} or {{mono|U}} | |
{{Plainlist|
}} | Long signed integer type. Capable of containing at least the {{closed-closed|size=100%|{{val|−2147483647}}, {{val|+2147483647}}}} range.{{efn|name=restr}} | ≥32 | %li or %ld | {{bracket|{{mono|LONG_MIN}}, {{mono|LONG_MAX}}}} | {{mono|l}} or {{mono|L}} | |
{{Plainlist|
}} | Long unsigned integer type. Capable of containing at least the {{closed-closed|size=100%|{{val|0}}, {{val|4294967295}}}} range. | ≥32 | %lu | {{bracket|0, {{mono|ULONG_MAX}}}} | both {{mono|u}} or {{mono|U}} and {{mono|l}} or {{mono|L}} | |
{{Plainlist|
}} | Long long signed integer type. Capable of containing at least the {{closed-closed|size=100%|{{val|−9223372036854775807}}, {{val|+9223372036854775807}}}} range.{{efn|name=restr}} Specified since the C99 version of the standard. | ≥64 | %lli or %lld | {{bracket|{{mono|LLONG_MIN}}, {{mono|LLONG_MAX}}}} | {{mono|ll}} or {{mono|LL}} | |
{{Plainlist|
}} | Long long unsigned integer type. Contains at least the {{closed-closed|size=100%|{{val|0}}, {{val|18446744073709551615}}}} range. Specified since the C99 version of the standard. | ≥64 | %llu | {{bracket|0, {{mono|ULLONG_MAX}}}} | both {{mono|u}} or {{mono|U}} and {{mono|ll}} or {{mono|LL}} | |
{{mono|float}} | Real floating-point type, usually referred to as a single-precision floating-point type. Actual properties unspecified (except minimum limits); however, on most systems, this is the IEEE 754 single-precision binary floating-point format (32 bits). This format is required by the optional Annex F "IEC 60559 floating-point arithmetic".
| | Converting from text:{{efn|These format strings also exist for formatting to text, but operate on a double.}}{{ubl | | | | }} | {{mono|f}} or {{mono|F}} | |||
{{mono|double}} | Real floating-point type, usually referred to as a double-precision floating-point type. Actual properties unspecified (except minimum limits); however, on most systems, this is the IEEE 754 double-precision binary floating-point format (64 bits). This format is required by the optional Annex F "IEC 60559 floating-point arithmetic".
| | {{ubl | | | | }} | none | |||
{{mono|long double}} | Real floating-point type, usually mapped to an extended precision floating-point number format. Actual properties unspecified. It can be either x86 extended-precision floating-point format (80 bits, but typically 96 bits or 128 bits in memory with padding bytes), the non-IEEE "double-double" (128 bits), IEEE 754 quadruple-precision floating-point format (128 bits), or the same as double. See the article on long double for details.
| | | {{mono|l}} or {{mono|L}} |
{{noteslist}}
The actual size of the integer types varies by implementation. The standard requires only size relations between the data types and minimum sizes for each data type:
The relation requirements are that the {{mono|long long}} is not smaller than {{mono|long}}, which is not smaller than {{mono|int}}, which is not smaller than {{mono|short}}. As {{mono|char}}'s size is always the minimum supported data type, no other data types (except bit-fields) can be smaller.
The minimum size for {{mono|char}} is 8 bits, the minimum size for {{mono|short}} and {{mono|int}} is 16 bits, for {{mono|long}} it is 32 bits and {{mono|long long}} must contain at least 64 bits.
The type {{mono|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. Because the data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.{{cite web|url=http://www.unix.org/version2/whatsnew/lp64_wp.html | title=64-Bit Programming Models: Why LP64? |publisher=The Open Group | access-date=9 November 2011}}
In practice, {{mono|char}} is usually 8 bits in size and {{mono|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 {{mono|char}} to be exactly 8 bits in size.{{Cite web |title=Width of Type (The GNU C Library) |url=https://www.gnu.org/software/libc/manual/html_node/Width-of-Type.html |access-date=2022-07-30 |website=www.gnu.org}}{{Cite web |title=
Various rules in the C standard make {{mono|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, and the possibility of aliasing.{{cite book | url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf | title=ISO/IEC 9899:1999 specification, TC3 | at=p. 67, § 6.5 Expressions}}
The actual size and behavior of floating-point types also vary by implementation. The only requirement is that {{mono|long double}} is not smaller than {{mono|double}}, which is not smaller than {{mono|float}}. Usually, the 32-bit and 64-bit IEEE 754 binary floating-point formats are used for {{mono|float}} and {{mono|double}} respectively.
The C99 standard includes new real floating-point types {{mono|float_t}} and {{mono|double_t}}, defined in <math.h>
. They correspond to the types used for the intermediate results of floating-point expressions when {{mono|FLT_EVAL_METHOD}} is 0, 1, or 2. These types may be wider than {{mono|long double}}.
C99 also added complex types: {{mono|float _Complex}}, {{mono|double _Complex}}, {{mono|long double _Complex}}. C11 added imaginary types (which were described in an informative annex of C99): {{mono|float _Imaginary}}, {{mono|double _Imaginary}}, {{mono|long double _Imaginary}}. Including the header <complex.h>
allows all these types to be accessed with using {{mono|complex}} and {{mono|imaginary}} respectively.
={{anchor|stdbool.h}}Boolean type=
C99 added a Boolean data type {{mono|_Bool}}. Additionally, the <stdbool.h>
header defines {{mono|bool}} as a convenient alias for this type, and also provides macros for true
and false
. {{mono|_Bool}} functions similarly to a normal integer type, with one exception: any assignments to a {{mono|_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 {{mono|bool}}, making the
header now useless.
unsigned char b = 256;
if (b) {
/* do something */
}
Variable b
evaluates to false if {{mono|unsigned char}} has a size of 8 bits. This is because the value 256 does not fit in the data type, which results in the lower 8 bits of it being used, resulting in a zero value. However, changing the type causes the previous code to behave normally:
_Bool b = 256;
if (b) {
/* do something */
}
The type {{mono|_Bool}} also ensures true values always compare equal to each other:
_Bool a = 1, b = 2;
if (a == b) {
/* this code will run */
}
In C23, {{mono|bool}} became a core functionality of the language, allowing for the following examples of code:
bool b = true;
if (b) {
/* this code will run */
}
=Bit-precise integer types=
Since C23, the language allows the programmer to define integers that have a width of an arbitrary number of bits. Those types are specified as {{code|_BitInt(N)|lang=c}}, where N is an integer constant expression that denotes the number of bits, including the sign bit for signed types, represented in two's complement. The maximum value of N is provided by BITINT_MAXWIDTH
and is at least ULLONG_WIDTH
. Therefore, the type {{code|_BitInt(2)|lang=c}} (or {{code|signed _BitInt(2)|lang=c}}) takes values from −2 to 1 while {{code|unsigned _BitInt(2)|lang=c}} takes values from 0 to 3. The type {{code|unsigned _BitInt(1)|lang=c}} also exists, being either 0 or 1 and has no equivalent signed type.{{cite book | url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3096.pdf| title=ISO/IEC 9899:2023 specification draft| at=p. 37, § 6.2.5 Types}}
={{anchor|stddef.h}}Size and pointer difference types=
The C language specification includes the {{mono|typedef}}s {{mono|size_t}} and {{mono|ptrdiff_t}} to represent memory-related quantities. Their size is defined according to the target processor's arithmetic capabilities, not the memory capabilities, such as available address space. Both of these types are defined in the
header (cstddef
in C++).
{{mono|size_t}} is an unsigned integer type used to represent the size of any object (including arrays) in the particular implementation. The operator {{mono|sizeof}} yields a value of the type {{mono|size_t}}. The maximum size of {{mono|size_t}} is provided via SIZE_MAX
, a macro constant which is defined in the <stdint.h>
header (cstdint
header in C++). {{mono|size_t}} is guaranteed to be at least 16 bits wide. Additionally, POSIX includes {{mono|ssize_t}}, which is a signed integer type of the same width as {{mono|size_t}}.
{{mono|ptrdiff_t}} is a signed integer type used to represent the difference between pointers. It is guaranteed to be valid only against pointers of the same type; subtraction of pointers consisting of different types is implementation-defined.
={{anchor|limits.h|float.h}}Interface to the properties of the basic types=
Information about the actual properties, such as size, of the basic arithmetic types, is provided via macro constants in two headers:
header (climits
header in C++) defines macros for integer types and
header (cfloat
header in C++) defines macros for floating-point types. The actual values depend on the implementation.
== Properties of integer types ==
CHAR_BIT
– size of the char type in bits, commonly referred to as the size of a byte (at least 8 bits)SCHAR_MIN
,SHRT_MIN
,INT_MIN
,LONG_MIN
,LLONG_MIN
(C99) – minimum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long longSCHAR_MAX
,SHRT_MAX
,INT_MAX
,LONG_MAX
,LLONG_MAX
(C99) – maximum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long longUCHAR_MAX
,USHRT_MAX
,UINT_MAX
,ULONG_MAX
,ULLONG_MAX
(C99) – maximum possible value of unsigned integer types: unsigned char, unsigned short, unsigned int, unsigned long, unsigned long longCHAR_MIN
– minimum possible value of charCHAR_MAX
– maximum possible value of charMB_LEN_MAX
– maximum number of bytes in a multibyte characterBOOL_WIDTH
(C23) - bit width of_Bool
, always 1CHAR_WIDTH
(C23) - bit width ofchar
;CHAR_WIDTH
,UCHAR_WIDTH
andSCHAR_WIDTH
are equal toCHAR_BIT
by definitionSCHAR_WIDTH
,SHRT_WIDTH
,INT_WIDTH
,LONG_WIDTH
,LLONG_WIDTH
(C23) - bit width ofsigned char
,short
,int
,long
, andlong long
respectivelyUCHAR_WIDTH
,USHRT_WIDTH
,UINT_WIDTH
,ULONG_WIDTH
,ULLONG_WIDTH
(C23) - bit width ofunsigned char
,unsigned short
,unsigned int
,unsigned long
, andunsigned long long
respectively
== Properties of floating-point types ==
FLT_MIN
,DBL_MIN
,LDBL_MIN
– minimum normalized positive value of float, double, long double respectivelyFLT_TRUE_MIN
,DBL_TRUE_MIN
,LDBL_TRUE_MIN
(C11) – minimum positive value of float, double, long double respectivelyFLT_MAX
,DBL_MAX
,LDBL_MAX
– maximum finite value of float, double, long double, respectivelyFLT_ROUNDS
– rounding mode for floating-point operationsFLT_EVAL_METHOD
(C99) – evaluation method of expressions involving different floating-point typesFLT_RADIX
– radix of the exponent in the floating-point typesFLT_DIG
,DBL_DIG
,LDBL_DIG
– number of decimal digits that can be represented without losing precision by float, double, long double, respectivelyFLT_EPSILON
,DBL_EPSILON
,LDBL_EPSILON
– difference between 1.0 and the next representable value of float, double, long double, respectivelyFLT_MANT_DIG
,DBL_MANT_DIG
,LDBL_MANT_DIG
– number ofFLT_RADIX
-base digits in the floating-point significand for types float, double, long double, respectivelyFLT_MIN_EXP
,DBL_MIN_EXP
,LDBL_MIN_EXP
– minimum negative integer such thatFLT_RADIX
raised to a power one less than that number is a normalized float, double, long double, respectivelyFLT_MIN_10_EXP
,DBL_MIN_10_EXP
,LDBL_MIN_10_EXP
– minimum negative integer such that 10 raised to that power is a normalized float, double, long double, respectivelyFLT_MAX_EXP
,DBL_MAX_EXP
,LDBL_MAX_EXP
– maximum positive integer such thatFLT_RADIX
raised to a power one less than that number is a normalized float, double, long double, respectivelyFLT_MAX_10_EXP
,DBL_MAX_10_EXP
,LDBL_MAX_10_EXP
– maximum positive integer such that 10 raised to that power is a normalized float, double, long double, respectivelyDECIMAL_DIG
(C99) – minimum number of decimal digits such that any number of the widest supported floating-point type can be represented in decimal with a precision ofDECIMAL_DIG
digits and read back in the original floating-point type without changing its value.DECIMAL_DIG
is at least 10.
{{anchor|stdint.h|inttypes.h}}Fixed-width integer types
The C99 standard includes definitions of several new integer types to enhance the portability of programs. The already available basic integer types were deemed insufficient, because their actual sizes are implementation defined and may vary across different systems. The new types are especially useful in embedded environments where hardware usually supports only several types and that support varies between different environments. All new types are defined in
header (cinttypes
header in C++) and also are available at
header (cstdint
header in C++). The types can be grouped into the following categories:
- Exact-width integer types that are guaranteed to have the same number n of bits across all implementations. Included only if it is available in the implementation.
- Least-width integer types that are guaranteed to be the smallest type available in the implementation, that has at least specified number n of bits. Guaranteed to be specified for at least N=8,16,32,64.
- Fastest integer types that are guaranteed to be the fastest integer type available in the implementation, that has at least specified number n of bits. Guaranteed to be specified for at least N=8,16,32,64.
- Pointer integer types that are guaranteed to be able to hold a pointer. Included only if it is available in the implementation.
- Maximum-width integer types that are guaranteed to be the largest integer type in the implementation.
The following table summarizes the types and the interface to acquire the implementation details (n refers to the number of bits):
class=wikitable |
rowspan=2 | Type category
! colspan=3 | Signed types ! colspan=3 | Unsigned types |
---|
Type
! Minimum value ! Maximum value ! Type ! Minimum value ! Maximum value |
Exact width
| | |
Least width
| | |
Fastest
| | |
Pointer
| | |
Maximum width
| | |
=Printf and scanf format specifiers=
{{Main|printf format string
|scanf format string}}
The
header (cinttypes
in C++) provides features that enhance the functionality of the types defined in the
header. It defines macros for printf format string and scanf format string specifiers corresponding to the types defined in
and several functions for working with the intmax_t
and uintmax_t
types. This header was added in C99.
==Printf format string==
The macros are in the format PRI{fmt}{type}
. Here {fmt} defines the output formatting and is one of d
(decimal), x
(hexadecimal), o
(octal), u
(unsigned) and i
(integer). {type} defines the type of the argument and is one of n
, FASTn
, LEASTn
, PTR
, MAX
, where n
corresponds to the number of bits in the argument.
==Scanf format string==
The macros are in the format SCN{fmt}{type}
. Here {fmt} defines the output formatting and is one of d
(decimal), x
(hexadecimal), o
(octal), u
(unsigned) and i
(integer). {type} defines the type of the argument and is one of n
, FASTn
, LEASTn
, PTR
, MAX
, where n
corresponds to the number of bits in the argument.
==Functions==
{{expand section|date=October 2011}}
Additional floating-point types
Similarly to the fixed-width integer types, ISO/IEC TS 18661 specifies floating-point types for IEEE 754 interchange and extended formats in binary and decimal:
_FloatN
for binary interchange formats;_DecimalN
for decimal interchange formats;_FloatNx
for binary extended formats;_DecimalNx
for decimal extended formats.
Structures
Structures aggregate the storage of multiple data items, of potentially differing data types, into one memory block referenced by a single variable. The following example declares the data type struct birthday
which contains the name and birthday of a person. The structure definition is followed by a declaration of the variable John
that allocates the needed storage.
struct birthday {
char name[20];
int day;
int month;
int year;
};
struct birthday John;
The memory layout of a structure is a language implementation issue for each platform, with a few restrictions. The memory address of the first member must be the same as the address of structure itself. Structures may be initialized or assigned to using compound literals. A function may directly return a structure, although this is often not efficient at run-time. Since C99, a structure may also end with a flexible array member.
A structure containing a pointer to a structure of its own type is commonly used to build linked data structures:
struct node {
int val;
struct node *next;
};
Arrays
For every type T
, except void and function types, there exist the types "array of N
elements of type T
". An array is a collection of values, all of the same type, stored contiguously in memory. An array of size N
is indexed by integers from 0
up to and including N−1
. Here is a brief example:
int cat[10]; // array of 10 elements, each of type int
Arrays can be initialized with a compound initializer, but not assigned. Arrays are passed to functions by passing a pointer to the first element. Multidimensional arrays are defined as "array of array …", and all except the outermost dimension must have compile-time constant size:
int a[10][8]; // array of 10 elements, each of type 'array of 8 int elements'
Pointers
{{See also|Pointer (computer programming)#C pointers}}
Every data type T
has a corresponding type pointer to T
. A pointer is a data type that contains the address of a storage location of a variable of a particular type. They are declared with the asterisk (*
) type declarator following the basic storage type and preceding the variable name. Whitespace before or after the asterisk is optional.
char *square;
long *circle;
int *oval;
Pointers may also be declared for pointer data types, thus creating multiple indirect pointers, such as {{mono|char **}} and {{mono|int ***}}, including pointers to array types. The latter are less common than an array of pointers, and their syntax may be confusing:
char *pc[10]; // array of 10 elements of 'pointer to char'
char (*pa)[10]; // pointer to a 10-element array of char
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 ({{code|1=sizeof *pa == 10|2=c}}).
Unions
{{See also|Union type#C/C++}}
A union type is a special construct that permits access to the same memory block by using a choice of differing type descriptions. For example, a union of data types may be declared to permit reading the same data either as an integer, a float, or any other user declared type:
union {
int i;
float f;
struct {
unsigned int u;
double d;
} s;
} u;
The total size of u
is the size of u.s
– which happens to be the sum of the sizes of u.s.u
and u.s.d
– since s
is larger than both i
and f
. When assigning something to u.i
, some parts of u.f
may be preserved if u.i
is smaller than u.f
.
Reading from a union member is not the same as casting since the value of the member is not converted, but merely read.
Function pointers
Function pointers allow referencing functions with a particular signature. For example, to store the address of the standard function abs
in the variable my_int_f
:
int (*my_int_f)(int) = &abs;
// the & operator can be omitted, but makes clear that the "address of" abs is used here
Function pointers are invoked by name just like normal function calls. Function pointers are separate from pointers and void pointers.
Type qualifiers
{{Main|Type qualifier}}
The aforementioned types can be characterized further by type qualifiers, yielding a qualified type. {{as of|2014}} and C11, there are four type qualifiers in standard C: const
(C89), volatile
(C89), restrict
(C99) and _Atomic
(C11){{snd}} the latter has a private name to avoid clashing with user names,[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3631.pdf C11:The New C Standard], Thomas Plum but the more ordinary name atomic
can be used if the
header is included. 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. The other qualifiers are used for low-level programming, and while widely used there, are rarely used by typical programmers.{{citation needed|date=September 2015}}
See also
{{Wikibooks|C Programming|Variables}}
References
{{Reflist}}
{{C programming language}}
{{Data types}}
{{DEFAULTSORT:C Variable Types And Declarations}}