標準庫標頭檔案 <cstdlib>
來自 cppreference.com
此標頭檔案最初是 C 標準庫中的 <stdlib.h>。
此標頭檔案提供各種實用程式。在此處定義的符號被多個庫元件使用。
型別 | ||
結構體型別,由 std::div 返回 (typedef) | ||
結構體型別,由 std::ldiv 返回 (typedef) | ||
(C++11) |
結構體型別,由 std::lldiv 返回 (typedef) | |
由 sizeof 運算子返回的無符號整型 (typedef) | ||
宏常量 | ||
指示程式執行狀態 (宏常量) | ||
MB_CUR_MAX |
當前區域設定下多位元組字元的最大位元組數 (宏常量) | |
實現定義的空指標常量 (宏常量) | ||
std::rand 生成的最大可能值 (宏常量) | ||
函式 | ||
程序控制 | ||
導致程式異常終止(不進行清理) (函式) | ||
導致程式正常終止並進行清理 (函式) | ||
(C++11) |
導致程式快速終止而不完全清理 (函式) | |
(C++11) |
導致程式正常終止而不進行清理 (函式) | |
註冊一個函式,在呼叫 std::exit() 時被呼叫 (函式) | ||
(C++11) |
註冊一個函式,在呼叫 std::quick_exit 時被呼叫 (函式) | |
呼叫宿主環境的命令處理器 (函式) | ||
訪問環境變數列表 (函式) | ||
記憶體管理 | ||
分配記憶體 (函式) | ||
(C++17) |
分配對齊記憶體 (函式) | |
分配並清零記憶體 (函式) | ||
擴充套件或收縮先前分配的記憶體塊 (函式) | ||
釋放先前分配的記憶體 (函式) | ||
數字字串轉換 | ||
將位元組字串轉換為浮點值 (函式) | ||
(C++11) |
將位元組字串轉換為整數值 (函式) | |
(C++11) |
將位元組字串轉換為整數值 (函式) | |
(C++11) |
將位元組字串轉換為無符號整數值 (函式) | |
將位元組字串轉換為浮點值 (函式) | ||
寬字串操作 | ||
返回下一個多位元組字元的位元組數 (函式) | ||
將下一個多位元組字元轉換為寬字元 (函式) | ||
將寬字元轉換為其多位元組表示 (函式) | ||
將窄多位元組字元字串轉換為寬字串 (函式) | ||
將寬字串轉換為窄多位元組字元字串 (函式) | ||
雜項演算法和數學 | ||
生成偽隨機數 (函式) | ||
為偽隨機數生成器播種 (函式) | ||
對未指定型別的元素範圍進行排序 (函式) | ||
在陣列中搜索未指定型別的元素 (函式) | ||
(C++11) |
計算整數值的絕對值 (|x|) (函式) | |
(C++11) |
計算整數除法的商和餘數 (函式) |
[編輯] 概要
namespace std { using size_t = /* see description */; // freestanding using div_t = /* see description */; // freestanding using ldiv_t = /* see description */; // freestanding using lldiv_t = /* see description */; // freestanding } #define NULL /* see description */ // freestanding #define EXIT_FAILURE /* see description */ // freestanding #define EXIT_SUCCESS /* see description */ // freestanding #define RAND_MAX /* see description */ #define MB_CUR_MAX /* see description */ namespace std { // Exposition-only function type aliases extern "C" using /* c-atexit-handler */ = void(); // exposition only extern "C++" using /* atexit-handler */ = void(); // exposition only extern "C" using /* c-compare-pred */ = // exposition only int(const void*, const void*); extern "C++" using /* compare-pred */ = // exposition only int(const void*, const void*); // start and termination [[noreturn]] void abort() noexcept; // freestanding int atexit(/* c-atexit-handler */* func) noexcept; // freestanding int atexit(/* atexit-handler */* func) noexcept; // freestanding int at_quick_exit(/* c-atexit-handler */* func) noexcept; // freestanding int at_quick_exit(/* atexit-handler */* func) noexcept; // freestanding [[noreturn]] void exit(int status); // freestanding [[noreturn]] void _Exit(int status) noexcept; // freestanding [[noreturn]] void quick_exit(int status) noexcept; // freestanding char* getenv(const char* name); int system(const char* string); // C library memory allocation void* aligned_alloc(size_t alignment, size_t size); void* calloc(size_t nmemb, size_t size); void free(void* ptr); void* malloc(size_t size); void* realloc(void* ptr, size_t size); double atof(const char* nptr); int atoi(const char* nptr); long int atol(const char* nptr); long long int atoll(const char* nptr); double strtod(const char* nptr, char** endptr); float strtof(const char* nptr, char** endptr); long double strtold(const char* nptr, char** endptr); long int strtol(const char* nptr, char** endptr, int base); long long int strtoll(const char* nptr, char** endptr, int base); unsigned long int strtoul(const char* nptr, char** endptr, int base); unsigned long long int strtoull(const char* nptr, char** endptr, int base); // multibyte / wide string and character conversion functions int mblen(const char* s, size_t n); int mbtowc(wchar_t* pwc, const char* s, size_t n); int wctomb(char* s, wchar_t wchar); size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n); size_t wcstombs(char* s, const wchar_t* pwcs, size_t n); // C standard library algorithms void* bsearch(const void* key, const void* base, // freestanding size_t nmemb, size_t size, /* c-compare-pred */* compar); void* bsearch(const void* key, const void* base, // freestanding size_t nmemb, size_t size, /* compare-pred */* compar); void qsort(void* base, size_t nmemb, size_t size, // freestanding /* c-compare-pred */* compar); void qsort(void* base, size_t nmemb, size_t size, // freestanding /* compare-pred */* compar); // low-quality random number generation int rand(); void srand(unsigned int seed); // absolute values constexpr int abs(int j); // freestanding constexpr long int abs(long int j); // freestanding constexpr long long int abs(long long int j); // freestanding constexpr /* floating-point-type */ abs(/* floating-point-type */ j); // freestanding-deleted constexpr long int labs(long int j); // freestanding constexpr long long int llabs(long long int j); // freestanding constexpr div_t div(int numer, int denom); // freestanding constexpr ldiv_t div(long int numer, long int denom); // freestanding constexpr lldiv_t div(long long int numer, long long int denom); // freestanding constexpr ldiv_t ldiv(long int numer, long int denom); // freestanding constexpr lldiv_t lldiv(long long int numer, long long int denom); // freestanding }
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 286 | C++98 | 在 <cstdlib> 中沒有提供 size_t 的定義 |
已提供 |