Special Types
These special types do not fit into any of the other categories, so they are grouped together arbitrarily,
void
The void
type is used to indicate the absence of type where it would it would normally be required. By definition, void
is an incomplete type that cannot be completed, so it is impossible to create, inspect, or manipulate an object of type void
. Nevertheless, it has three important uses:
A function declared as returning
void
does not return anythingA function declared with
void
as its parameter list has no parametersA pointer to
void
(i.e.void *
) is a universal pointer which can point to an object of any type. Pointers to a particular type may be freely converted to pointers to void and back again without loss of information; this is often used to implement parametric polymorphism (type-generic programming).
char
A char
(pronounced /t͡ʃɑɹ/, as in char-coal) is the smallest and most fundamental data type, defined to have a size of 1 (i.e. sizeof (char) == 1
) and is often synonymous with byte. The char
type is used for representing ASCII-encoded characters, which is the basis for its name. The macro, CHAR_BIT
, is defined by the implementation as the number of bits in a char
and must be at least 8. It is unspecified whether char
is a signed or unsigned type, and it should be used only for holding ASCII-encoded text.
It is inappropriate to use char
to hold numeric values; instead, the signed char
and unsigned char
types are provided as the smallest integer types. The three types are in fact separate and distinct types, and should not be mixed up.
Enumeration Types
An enumeration (enum
) is a set of named integer constants, called enumeration constants, which are automatically assigned sequentially increasing values (but may be explicitly assigned specific values). These are often used to represent groups of related constants, unique identifiers, and states. Enumeration constants can also be used in contexts where compile-time constant values are required, such as the size of an array.