Chapter 15. The Standard Headers

Each standard library function is declared in one or more of the standard headers . These headers also contain all the macro and type definitions that the C standard provides. This chapter describes the contents and use of the standard headers.

Each of the standard headers contains a set of related function declarations, macros, and type definitions. The standard headers are also called header files , as the contents of each header are usually stored in a file. Strictly speaking, however, the standard does not require the headers to be organized in files.

The C standard defines the following 24 headers. Those marked with an asterisk have been added in C99.

assert.h

inttypes.h*

signal.h

stdlib.h

complex.h*

iso646.h

stdarg.h

string.h

ctype.h

limits.h

stdbool.h*

tgmath.h*

errno.h

locale.h

stddef.h

time.h

fenv.h*

math.h

stdint.h*

wchar.h

float.h

setjmp.h

stdio.h

wctype.h

Using the Standard Headers

You can add the contents of a standard header to a source file by inserting an #include directive, which must be placed outside all functions. You can include the standard headers as many times as you want, and in any order. However, before the #include directive for any header, your program must not define any macro with the same name as an identifier in that header. To make sure that your programs respect this condition, always include the required standard headers at the beginning of your source files, before any header files of your own.

Execution Environments

C programs run in one ...

Get C in a Nutshell 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.