stdlib.h(0P)
π stdlib.h(0P) β POSIX Programmer's Manual π
okay bestie, welcome to the manual page for stdlib.h from the POSIX Programmer's Manual β yes that's the standard library definitions, the header that literally everything you've ever written has quietly leaned on. π«Ά
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
ngl that's the standard little disclaimer that shows up on all of these, but it's real and it matters β Linux might do its own thing, so if you're on Linux, go check the Linux page too. Don't come for me, I'm just the messenger. π
β¨ NAME β¨
stdlib.h β standard library definitions
that's it, that's the name, and honestly it's giving main character of the C standard library. π
π SYNOPSIS π
#include <stdlib.h>
one line, that's the whole vibe. no arguments, no drama. β¨
π DESCRIPTION π
okay so here's the tea. Some of the functionality described on this reference page extends the ISO C standard. Which means: applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header. fr fr, no feature test macro, no symbols, no cap. π«
π Macros that expand to integer constant expressions π
The <stdlib.h> header shall define the following macros which shall expand to integer constant expressions:
EXIT_FAILUREβ unsuccessful termination forexit(); it evaluates to a non-zero value. it's giving "we did not slay today" πEXIT_SUCCESSβ successful termination forexit(); it evaluates to0. the iconic happy ending. β¨{RAND_MAX}β maximum value returned byrand(); at least32767. that's the ceiling, bestie, and it's a lowkey one.
π¦ The size_t macro π¦
The <stdlib.h> header shall define the following macro which shall expand to a positive integer expression with type size_t:
{MB_CUR_MAX}β maximum number of bytes in a character specified by the current locale (categoryLC_CTYPE).
and in the POSIX locale, the value of {MB_CUR_MAX} shall be 1. periodt. π
π NULL and friends π
The <stdlib.h> header shall define NULL as described in <stddef.h>.
π§ Data types (through typedef) π§
The <stdlib.h> header shall define the following data types through typedef:
div_tβ structure type returned by thediv()function.ldiv_tβ structure type returned by theldiv()function.lldiv_tβ structure type returned by thelldiv()function.size_tβ as described in<stddef.h>.wchar_tβ as described in<stddef.h>.
π Wait there's more β symbolic constants and macros π
In addition, the <stdlib.h> header shall define the following symbolic constants and macros as described in <sys/wait.h>:
WEXITSTATUSWIFEXITEDWIFSIGNALEDWIFSTOPPEDWNOHANGWSTOPSIGWTERMSIGWUNTRACED
all eight of them, we're not skipping a single one, the way that a header just casually hands you wait-status macros. obsessed. π«Ά
π The functions π
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
void _Exit(int);
long a64l(const char *);
void abort(void);
int abs(int);
int atexit(void (*)(void));
double atof(const char *);
int atoi(const char *);
long atol(const char *);
long long atoll(const char *);
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
void *calloc(size_t, size_t);
div_t div(int, int);
double drand48(void);
double erand48(unsigned short [3]);
void exit(int);
void free(void *);
char *getenv(const char *);
int getsubopt(char **, char *const *, char **);
int grantpt(int);
char *initstate(unsigned, char *, size_t);
long jrand48(unsigned short [3]);
char *l64a(long);
long labs(long);
void lcong48(unsigned short [7]);
ldiv_t ldiv(long, long);
long long llabs(long long);
lldiv_t lldiv(long long, long long);
long lrand48(void);
void *malloc(size_t);
int mblen(const char *, size_t);
size_t mbstowcs(wchar_t *restrict, const char *restrict, size_t);
int mbtowc(wchar_t *restrict, const char *restrict, size_t);
char *mkdtemp(char *);
int mkstemp(char *);
long mrand48(void);
long nrand48(unsigned short [3]);
int posix_memalign(void **, size_t, size_t);
int posix_openpt(int);
char *ptsname(int);
int putenv(char *);
void qsort(void *, size_t, size_t, int (*)(const void *,
const void *));
int rand(void);
int rand_r(unsigned *);
long random(void);
void *realloc(void *, size_t);
char *realpath(const char *restrict, char *restrict);
unsigned short *seed48(unsigned short [3]);
int setenv(const char *, const char *, int);
void setkey(const char *);
char *setstate(char *);
void srand(unsigned);
void srand48(long);
void srandom(unsigned);
double strtod(const char *restrict, char **restrict);
float strtof(const char *restrict, char **restrict);
long strtol(const char *restrict, char **restrict, int);
long double strtold(const char *restrict, char **restrict);
long long strtoll(const char *restrict, char **restrict, int);
unsigned long strtoul(const char *restrict, char **restrict, int);
unsigned long long
strtoull(const char *restrict, char **restrict, int);
int system(const char *);
int unlockpt(int);
int unsetenv(const char *);
size_t wcstombs(char *restrict, const wchar_t *restrict, size_t);
int wctomb(char *, wchar_t);
look at that list. malloc, free, exit, qsort, strtod, the whole pty crew (grantpt, posix_openpt, ptsname, unlockpt), the entire lrand48 family, and yes, _Exit with the dramatic capital E. it's giving legendary lineup. π₯
and heads up: inclusion of the <stdlib.h> header may also make visible all symbols from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>. surprise bonus content, we love a header that over-shares. π
π Note
The following sections are informative.
so like... read them for context, not for rules. iykyk. π
πΈ APPLICATION USAGE πΈ
None.
literally nothing. the section said "no thoughts, head empty." π
β¨ RATIONALE β¨
None.
same energy. nothing here either, bestie. π
π¦ FUTURE DIRECTIONS π¦
None.
no plans, no promises, just vibes. β¨
π SEE ALSO π
<limits.h><math.h><stddef.h><sys_types.h><sys_wait.h>
The System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment, _Exit(), a64l(), abort(), abs(), atexit(), atof(), atoi(), atol(), bsearch(), calloc(), div(), drand48(), exit(), free(), getenv(), getsubopt(), grantpt(), initstate(), labs(), ldiv(), malloc(), mblen(), mbstowcs(), mbtowc(), mkdtemp(), posix_memalign(), posix_openpt(), ptsname(), putenv(), qsort(), rand(), realloc(), realpath(), setenv(), setkey(), strtod(), strtol(), strtoul(), system(), unlockpt(), unsetenv(), wcstombs(), wctomb()
that's the whole bestie list, every single one. go read them, they're all iconic in their own right. π
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π
β¨ this one came to you courtesy of IEEE/The Open Group, 2017 β stdlib.h(0P), the manual page that ate and left no crumbs. now go #include <stdlib.h> and slay responsibly. π«Άπ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms