Chapter 2. Types
Programs have to store and process different kinds of data, such as integers and floating-point numbers, in different ways. To this end, the compiler needs to know what kind of data a given value represents.
In C, the term object refers to a location in memory whose contents can represent values. Objects that have names are also called variables. An object’s type determines how much space the object occupies in memory, and how its possible values are encoded. For example, the same pattern of bits can represent completely different integers depending on whether the data object is interpreted as signed (that is, either positive or negative) or unsigned (and hence unable to represent negative values).
Typology
The types in C can be classified as follows:
-
Basic types
-
Standard and extended integer types
-
Real and complex floating-point types
-
-
Enumerated types
-
The type
void
-
Derived types
-
Pointer types
-
Array types
-
Structure types
-
-
Union types
-
Function types
The basic types and the enumerated types together make up the arithmetic types. The arithmetic types and the pointer types together are called the scalar types. Finally, array types and structure types are referred to collectively as the aggregate types. (Union types are not considered aggregate because only one of their members can store a value at any given time.)
A function type describes the interface to a function; that is, it specifies the type of the function’s return value, and ...
Get C in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.