- Stdlib.h
stdlib.h is the header of the general purpose standard library of
C programming language which includes functions involving memory allocation, process control, conversions and others. It is compatible withC++ and is known ascstdlib
in C++. The name "stdlib" stands for standard library.Member functions
Members of the
stdlib.h
can be classified into the following categories: conversion, memory, process control, sort and search, mathematics.Member constants
The
stdlib.h
andstddef.h
header files define the macro NULL, which yields anull pointer constant, and represents a pointer value that is guaranteed not to point to a valid address in memory. NULL may be defined as a constant expression equal to int zero, long int zero, or zero cast to a void * pointer:Note: Although the
null pointer constant is always represented in C by the symbolic constant 0 or by 0 cast to a void pointer, the actual bit representation of such a pointer is system-specific and might not be all-bits-zero.Member data types
The
stdlib.h
library is required to define adatatype calledsize_t
[As per theC99 standard ISO/IEC 9899, Section "7.20 General utilities" (point number 2) and Appendix "B.19 General utilities ] which is used to represent the size of an object. Library functions that take sizes expect them to be of type". The definition can also provided by stddef.h if one wants to avoid including the whole of stdlib.size_t
, and thesizeof
operator evaluates tosize_t
.The actual type of
size_t
is platform-dependent; a common mistake is to assumesize_t
is the same asunsigned int
, which can lead to programming errors [http://www.gamedev.net/reference/programming/features/20issues64bit/] ,particularly as 64-bit architectures become more prevalent.Two less widely used datatypes,
div_t
andldiv_t
, are also defined. They are the return types of the div and ldiv functions. The standard defines them as:Nonstandard functions
itoa is a common function that is included in many implementations of stdlib.h, but the standard does not define the function. It may have been included because of its appearance in "The C Programming Language". The same effect can be achieved withsprintf , which is defined in the standard.ee also
*
stdio.h
*C standard library References
* [http://www.cplusplus.com/ref/cstdlib/ stdlib.h summary on cplusplus.com] , accessed in February 2006.
* [http://www.embedded.com/columns/programmingpointers/200900195?pgno=1 Why size_t matters]
Wikimedia Foundation. 2010.