The C and C Standard Libraries

The C and C++ Standard Libraries

Neither C nor C++ have keywords that perform I/O, manipulate strings, perform various mathematical computations, or a number of other useful procedures. These things are accomplished by using a set of predefined library functions that are supplied with the compiler. There are two basic styles of libraries: the C function library, which is supplied with all C and C++ compilers, and the C++ class library, which applies only to C++. Both libraries are summarized later in this guide.

Before your program can use a library function, it must include the appropriate header. In general, headers are usually files, but they are not necessarily files. It is permissible for a compiler to predefine the contents of a header internally. However, for all practical purposes, the standard C headers are contained in files that correspond to their names. The following table shows the standard headers defined by C89, along with those added by the 1995 Amendment 1.




The assert( ) macro


Character handling


Error reporting


Implementation-dependent floating-point limits


Macros that correspond to various operators, such as && and ^; added in 1995 by Amendment 1


Various implementation-dependent limits




Various definitions used by the math library


Nonlocal jumps


Signal values


Variable-length argument lists


Commonly used constants


File I/O


Miscellaneous declarations


String functions


System time and date functions


Multibyte and wide-character functions; added in 1995 by Amendment 1


Multibyte and wide-character classification functions; added in 1995 by Amendment 1

The following table shows those headers added by C99.




Complex arithmetic.


The floating-point status flags and other aspects of the floating-point environment.


Standard, portable set of integer type names; also supports functions that handle greatest-width integers.


Boolean data types and defines the macro bool, which helps with C++ compatibility.


Standard, portable set of integer type names. This file is included by <inttypes.h>.


Type-generic floating-point macros.

For C++, headers are specified using standard header names, which do not end with .h. Thus, the C++ headers do not specify filenames. Instead, they are simply standard identifiers that the compiler can handle as it sees fit. This means that a header may be mapped to a filename, but this is not required. The C++ headers are shown here. Those associated either directly or indirectly with the Standard Template Library (STL) are indicated.

C++ Header



Various operations on containers (STL)


Bitsets (STL)


Complex numbers


Double-ended queues (STL)


Exception handling


Stream-based file I/O


Various function objects (STL)


I/O manipulators


Low-level I/O classes


Forward declarations for I/O system


Standard I/O classes


Input streams


Access to contents of containers (STL)


Various implementation limits


Linear lists (STL)


Localization-specific information


Maps (keys with values) (STL)


Memory allocation via allocators (STL)


Memory allocation using new


General-purpose numeric operations (STL)


Output streams


Queues (STL)


Sets (STL)


String streams


Stacks (STL)


Standard exceptions


Buffered streams


Standard string class (STL)


Runtime type information


General purpose templates (STL)


Operations on arrays containing values


Vectors (dynamic arrays) (STL)

C++ also defines the following headers that correspond to the C headers (except those added by C99).



















In standard C++, all of the information relating to the standard library is defined under the std namespace. Thus, to gain direct access to these items, you will need to include the following using statement after including the necessary headers:

using namespace std; 

Alternatively, you can qualify each library identifier with std::, such as std::cout, rather than bringing the entire library into the global namespace. However, qualifying each name can get to be tedious.

Programming Tip 

If you are using an older C++ compiler, then it may not support the modern-style C++ headers or the namespace command. If this is the case, then you will need to use the older, traditional-style headers. These use the same names as the modern headers but include the .h (thus, they resemble C headers). For example, the following includes <iostream> using the traditional approach:

#include <iostream.h> 

When using the traditional-style header, all of the names defined by the header are placed in the global namespace, not the one defined by std. Thus, no using statement is required.

C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539 © 2008-2017.
If you may any questions please contact us: