Copyright © 2024 by
Rance D. Necaise
|
|
2.3 The Standard LibraryC has no built-in functions as part of the language itself, but it does have a large standard library. A library is a collection of code that has been written and compiled by someone else, ready for use in a C program. A standard library is a library that is considered part of the language and must be included with the compiler for that language. The C standard library provides a large collection of type definitions, functions, and constant variables for solving a wide range of problems from basic tasks such as string processing, and mathematical computations to the more advanced like memory management and the utilization of operating system services. Include DirectiveThe C standard library is organized into modules. Related functions and data types are grouped together in the same module.
To utilize the resources provided by a module, the module must be explicitly included in your program before they can be used. The #include <math.h> Modules must be included at the top of your source program, which is typically done immediately following the file comment. Here, the /* hello.cc A sample C program. */ #include <stdio.h> int main() { printf("Hello World!\n"); } Modules in C are comprised of two files: a header file and a source or implementation file. The two files have the same name, but different extensions. The header file is identified by the extension Standard Library ModulesThe C standard library is officially comprised of 29 modules. Additional standard modules for accessing and working system services are defined by the various operating systems. While a large number of modules are available, most C programs use only a small subset of those. The more commonly used modules are shown in Table 1.
Table 1: Commonly used C standard library modules.
|