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.


The types in C can be classified as follows:

  • Basic type

    • 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 may also specify the types of all the parameters ...

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.