O'Reilly logo

Professional C++ by Scott J. Kleper, Nicholas A. Solter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required