Namespaces
Variants
Actions

Standard library header <stdlib.h>

From cppreference.com
< c‎ | header

This header is a part of program support utilities library, in particular, it provides functions for program termination, memory management, string conversions, random numbers generation. The header also provides some algorithms.

Functions

causes abnormal program termination (without cleaning up)
(function)[edit]
causes normal program termination with cleaning up
(function)[edit]
causes normal program termination without completely cleaning up
(function)[edit]
(C99)
causes normal program termination without cleaning up
(function)[edit]
registers a function to be called on exit() invocation
(function)[edit]
registers a function to be called on quick_exit invocation
(function)[edit]
indicates program execution execution status
(macro constant)[edit]

[edit]Synopsis

#define __STDC_VERSION_STDLIB_H__ 202311L   // TODO: types and macros   voidcall_once(once_flag* flag, void(*func)(void));doubleatof(constchar* nptr);intatoi(constchar* nptr);longintatol(constchar* nptr);longlongintatoll(constchar* nptr);int strfromd(char*restrict s, size_t n, constchar*restrict format, double fp);int strfromf(char*restrict s, size_t n, constchar*restrict format, float fp);int strfroml(char*restrict s, size_t n, constchar*restrict format, longdouble fp);doublestrtod(constchar*restrict nptr, char**restrict endptr);floatstrtof(constchar*restrict nptr, char**restrict endptr);longdoublestrtold(constchar*restrict nptr, char**restrict endptr);longintstrtol(constchar*restrict nptr, char**restrict endptr, int base);longlongintstrtoll(constchar*restrict nptr, char**restrict endptr, int base);unsignedlongintstrtoul(constchar*restrict nptr, char**restrict endptr, int base);unsignedlonglongintstrtoull(constchar*restrict nptr, char**restrict endptr, int base);intrand(void);voidsrand(unsignedint seed);void* aligned_alloc(size_t alignment, size_t size);void*calloc(size_t nmemb, size_t size);voidfree(void* ptr);void free_sized(void* ptr, size_t size);void free_aligned_sized(void* ptr, size_t alignment, size_t size);void*malloc(size_t size);void*realloc(void* ptr, size_t size);[[noreturn]]voidabort(void);intatexit(void(*func)(void));intat_quick_exit(void(*func)(void));[[noreturn]]voidexit(int status);[[noreturn]]void_Exit(int status);char*getenv(constchar* name);[[noreturn]]voidquick_exit(int status);intsystem(constchar* string); QVoid*bsearch(constvoid* key, QVoid* base, size_t nmemb, size_t size, int(*compar)(constvoid* , constvoid*));voidqsort(void* base, size_t nmemb, size_t size, int(*compar)(constvoid* , constvoid*));intabs(int j);longintlabs(longint j);longlongintllabs(longlongint j); div_t div(int numer, int denom); ldiv_t ldiv(longint numer, longint denom); lldiv_t lldiv(longlongint numer, longlongint denom);intmblen(constchar* s, size_t n);intmbtowc(wchar_t*restrict pwc, constchar*restrict s, size_t n);intwctomb(char* s, wchar_t wc);size_tmbstowcs(wchar_t*restrict pwcs, constchar*restrict s, size_t n);size_twcstombs(char*restrict s, constwchar_t*restrict pwcs, size_t n);size_t memalignment(constvoid* p);

Only if the implementation defines __STDC_IEC_60559_DFP__:

int strfromd32(char*restrict s, size_t n, constchar*restrict format, _Decimal32 fp);int strfromd64(char*restrict s, size_t n, constchar*restrict format, _Decimal64 fp);int strfromd128(char*restrict s, size_t n, constchar*restrict format, _Decimal128 fp); _Decimal32 strtod32(constchar*restrict nptr, char**restrict endptr); _Decimal64 strtod64(constchar*restrict nptr, char**restrict endptr); _Decimal128 strtod128(constchar*restrict nptr, char**restrict endptr);

Only if the implementation defines __STDC_IEC_60559_TYPES__ and additionally the user code defines __STDC_WANT_IEC_60559_TYPES_EXT__ before any inclusion of <stdlib.h>:

#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__int strfromfN(char*restrict s, size_t n, constchar*restrict format, _FloatN fp);int strfromfNx(char*restrict s, size_t n, constchar*restrict format, _FloatNx fp);int strfromdN(char*restrict s, size_t n, constchar*restrict format, _DecimalN fp);int strfromdNx(char*restrict s, size_t n, constchar*restrict format, _DecimalNx fp); _FloatN strtofN(constchar*restrict nptr, char**restrict endptr); _FloatNx strtofNx(constchar*restrict nptr, char**restrict endptr); _DecimalN strtodN(constchar*restrict nptr, char**restrict endptr); _DecimalNx strtodNx(constchar*restrict nptr, char**restrict endptr);int strfromencfN(char*restrict s, size_t n, constchar*restrict format, constunsignedchar encptr[restrictstatic N/8]);int strfromencdecdN(char*restrict s, size_t n, constchar*restrict format, constunsignedchar encptr[restrictstatic N/8]);int strfromencbindN(char*restrict s, size_t n, constchar*restrict format, constunsignedchar encptr[restrictstatic N/8]);void strtoencfN(unsignedchar encptr[restrictstatic N/8], constchar*restrict nptr, char**restrict endptr);void strtoencdecdN(unsignedchar encptr[restrictstatic N/8], constchar*restrict nptr, char**restrict endptr);void strtoencbindN(unsignedchar encptr[restrictstatic N/8], constchar*restrict nptr, char**restrict endptr);#endif

Only if the implementation defines __STDC_LIB_EXT1__ and additionally the user code defines __STDC_WANT_LIB_EXT1__ before any inclusion of stdio.h:

#if defined(__STDC_WANT_LIB_EXT1__) constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);void abort_handler_s(constchar*restrict msg, void*restrict ptr, errno_t error);void ignore_handler_s(constchar*restrict msg, void*restrict ptr, errno_t error); errno_t getenv_s(size_t*restrict len, char*restrict value, rsize_t maxsize, constchar*restrict name); QVoid* bsearch_s(constvoid* key, QVoid* base, rsize_t nmemb, rsize_t size, int(*compar)(constvoid* k, constvoid* y, void* context), void* context); errno_t qsort_s(void* base, rsize_t nmemb, rsize_t size, int(*compar)(constvoid* x, constvoid* y, void* context), void* context); errno_t wctomb_s(int*restrict status, char*restrict s, rsize_t smax, wchar_t wc); errno_t mbstowcs_s(size_t*restrict retval, wchar_t*restrict dst, rsize_t dstmax, constchar*restrict src, rsize_t len); errno_t wcstombs_s(size_t*restrict retval, char*restrict dst, rsize_t dstmax, constwchar_t*restrict src, rsize_t len);#endif
close