"Never put off until run time what you can do at compile time." -- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
C Runtime Library Reference
Routines by category
The descriptions below relate to some of the more popular functions of the runtime library. Details on each category of functions can be viewed by following the links to the online documentation. Most of the functions are ANSI compatible, but a few are OS (Windows) specific.
The va_arg, va_end, and va_start macros provide access to function arguments when the number of arguments is variable. These macros are defined in STDARG.H for ANSI C compatibility, and in VARARGS.H for compatibility with UNIX System V.#include <stdarg.h>
These routines work with areas of memory on a byte-by-byte basis. You can copy blocks of memory from one buffer to another, search through memory, set entire blocks of memory to a specific value, etc.#include <string.h>
Each of these routines tests a specified single-byte character, wide character, or multibyte character for satisfaction of a condition. (By definition, the ASCII character set is a subset of all multibyte-character sets. For example, Japanese katakana includes ASCII as well as non-ASCII characters.) Generally these routines execute faster than tests you might write.#include <ctype.h>
Functionality includes: testing characters to see if they are numbers, lowercase, uppercase, whitespace, punctuation, hexadecimal, etc.
These routines convert data from one form to another. Generally these routines execute faster than conversions you might write. Each routine that begins with a to prefix is implemented as a function and as a macro.#include <stdlib.h>
Funtionality includes: converting numbers to strings, strings to numbers, converting letters/strings to upper/lower case, converting characters to ASCII codes, etc.
These routines access, modify, and obtain information about the directory structure. That is, you can create directories, remove directories, change directories, search directories, get free disk space, etc.#include <direct.h>
This is not part of the ANSI Standard. (OS-specific routines.)
Use these routines to create, delete, and manipulate files and to set and check file-access permissions.#include <io.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h>
Functionality includes: getting/setting a file's time and date, renaming files, deleting files, parsing paths into components, opening files for reading/writing, getting/setting file permissions, etc.
Some routines are not part of the ANSI Standard. (OS-specific routines.)
These library routines provide support for math related functions such as: sin, cos, exp, floor, sqrt, log, rand, etc.#include <math.h>
The I/O functions read and write data to and from files and devices. File I/O operations take place in text mode or binary mode. The functions from conio.h are Microsoft-specific functions.#include <io.h> #include <stdio.h> #include <conio.h>
Functionality includes: open/close files, seek, read/write characters or blocks, binary/text support, reading/writing to stdin, stdout, sterr, flushing files, etc.
These routines allocate, free, and reallocate memory.#include <stdlib.h> #include <malloc.h>
Functionality includes: allocating, freeing (deallocating), initializing, reallocating, etc.
These routines start, stop, and manage processes from within a program. Use the environment-control routines to get and change information about the operating-system environment.#include <process.h> #include <stdlib.h>
Functionality includes: aborting programs, exiting from processes, executing other programs, handling signals, etc.
Functions for searching and sorting.#include <stdlib.h>
Functionality includes: linear search, binary search, and quick sort.
Functions that operate on null-terminated single-byte character, wide-character, and multibyte-character strings. Use the buffer-manipulation routines to work with character arrays that do not end with a null character#include <string.h>
Functionality includes: searching strings for substrings and characters, concatenating strings, finding string lengths, comparing strings, setting characters of a string, etc.
Use these functions to get the current time and convert, adjust, and store it as necessary. The current time is the system time.#include <time.h>
Functions include: getting the current system time, formatting data and time values, converting time formats, computing difference between two times, etc.