Chapter 27. Standard Library Header Files

The interface to the C++ Standard Library consists of 51 header files, 18 of which present the C standard library. It's often difficult to remember which header files you need to include in your program files, so this material provides a brief description of the contents of each header, organized into seven categories:

  • The C Standard Library

  • Containers

  • Algorithms, iterators, and allocators

  • Utilities

  • Exceptions

  • Numerical processing

  • I/O Streams

The C Standard Library

The C++ Standard Library includes the entire C Standard Library. The header files are generally the same, except for two points:

  • The header names are <cname> instead of <name.h>.

  • All the names declared in the header files are in namespace std.

For backward compatibility, you can still include <name.h> if you want. That puts the names into the global namespace instead of into namespace std. We recommend avoiding this feature.

The following table provides a summary of the most useful functionality:

Header File Name

Contents

<cassert>

assert() macro.

<cctype>

Character predicates and manipulation functions, such as isspace() and tolower().

<cerrno>

Defines errno expression.

<cfloat>

C-style defines related to floating-point arithmetic, such as FLT_MAX

<ciso646>

In C, the <iso646.h> file defines macros and, or, etc. In C++, those are keywords, so they are not in this header.

<climits>

C-style limit defines, such as INT_MAX.

<clocale>

A few localization macros and functions like LC_ALL and setlocale().

<cmath> ...

Get Professional C++ 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.