Namespaces
Variants

Standard library header <stdlib.h>

From cppreference.net

이 헤더는 프로그램 지원 유틸리티 라이브러리의 일부로, 특히 프로그램 종료, 메모리 관리 , 문자열 변환 , 난수 생성을 위한 함수들을 제공합니다. 또한 이 헤더는 몇 가지 알고리즘 도 제공합니다.

함수

비정상적인 프로그램 종료를 유발합니다 (정리 작업 없음)
(함수)
정리 작업과 함께 정상적인 프로그램 종료를 유발합니다
(함수)
완전한 정리 작업 없이 정상적인 프로그램 종료를 유발합니다
(함수)
(C99)
정리 작업 없이 정상적인 프로그램 종료를 유발합니다
(함수)
exit() 호출 시 실행될 함수를 등록합니다
(함수)
quick_exit 호출 시 실행될 함수를 등록합니다
(함수)
프로그램 실행 상태를 나타냅니다
(매크로 상수)

시놉시스

#define __STDC_VERSION_STDLIB_H__ 202311L
// TODO: 타입과 매크로
void call_once(once_flag* flag, void (*func)(void));
double atof(const char* nptr);
int atoi(const char* nptr);
long int atol(const char* nptr);
long long int atoll(const char* nptr);
int strfromd(char* restrict s, size_t n, const char* restrict format, double fp);
int strfromf(char* restrict s, size_t n, const char* restrict format, float fp);
int strfroml(char* restrict s, size_t n, const char* restrict format, long double fp);
double strtod(const char* restrict nptr, char** restrict endptr);
float strtof(const char* restrict nptr, char** restrict endptr);
long double strtold(const char* restrict nptr, char** restrict endptr);
long int strtol(const char* restrict nptr, char** restrict endptr, int base);
long long int strtoll(const char* restrict nptr, char** restrict endptr, int base);
unsigned long int strtoul(const char* restrict nptr, char** restrict endptr, int base);
unsigned long long int strtoull(const char* restrict nptr,
                                char** restrict endptr, int base);
int rand(void);
void srand(unsigned int seed);
void* aligned_alloc(size_t alignment, size_t size);
void* calloc(size_t nmemb, size_t size);
void free(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]] void abort(void);
int atexit(void (*func)(void));
int at_quick_exit(void (*func)(void));
[[noreturn]] void exit(int status);
[[noreturn]] void _Exit(int status);
char* getenv(const char* name);
[[noreturn]] void quick_exit(int status);
int system(const char* string);
QVoid* bsearch(const void* key, QVoid* base, size_t nmemb, size_t size,
               int (*compar)(const void* , const void* ));
void qsort(void* base, size_t nmemb, size_t size,
           int (*compar)(const void* , const void* ));
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
div_t div(int numer, int denom);
ldiv_t ldiv(long int numer, long int denom);
lldiv_t lldiv(long long int numer, long long int denom);
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
int wctomb(char* s, wchar_t wc);
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
size_t memalignment(const void* p);

구현이 __STDC_IEC_60559_DFP__ 를 정의하는 경우에만:

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

구현이 __STDC_IEC_60559_TYPES__ 를 정의하고, 추가로 사용자 코드가 <stdlib.h> 를 포함하기 전에 __STDC_WANT_IEC_60559_TYPES_EXT__ 를 정의한 경우에만:

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

구현이 __STDC_LIB_EXT1__ 를 정의하고, 추가로 사용자 코드가 stdio.h 를 포함하기 전에 __STDC_WANT_LIB_EXT1__ 를 정의한 경우에만:

#if defined(__STDC_WANT_LIB_EXT1__)
constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);
void abort_handler_s(const char* restrict msg, void* restrict ptr, errno_t error);
void ignore_handler_s(const char* restrict msg, void* restrict ptr, errno_t error);
errno_t getenv_s(size_t* restrict len, char* restrict value, rsize_t maxsize,
                 const char* restrict name);
QVoid* bsearch_s(const void* key, QVoid* base, rsize_t nmemb, rsize_t size,
                 int (*compar)(const void* k, const void* y, void* context),
                               void* context);
errno_t qsort_s(void* base, rsize_t nmemb, rsize_t size,
                int (*compar)(const void* x, const void* 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,
                   const char* restrict src, rsize_t len);
errno_t wcstombs_s(size_t* restrict retval, char* restrict dst, rsize_t dstmax,
                   const wchar_t* restrict src, rsize_t len);
#endif
**참고:** 제공된 HTML 코드 블록 내에는 번역이 필요한 일반 텍스트가 포함되어 있지 않습니다. 모든 내용은 C++ 코드와 HTML 태그로 구성되어 있으며, 지시사항에 따라 다음 항목들은 번역에서 제외되었습니다: - 모든 HTML 태그와 속성 - ` `, `
`, `` 태그 내부의 텍스트
- C++ 관련 용어(함수명, 타입명, 키워드 등)
따라서 원본 코드는 완전히 보존된 상태로 유지됩니다.