# C 標準庫 - <stdlib.h>
## 簡介
**stdlib .h** 頭文件定義了四個變量類型、一些宏和各種通用工具函數。
## 庫變量
下面是頭文件 stdlib.h 中定義的變量類型:
| 變量 | 描述 |
| --- | --- |
| **size_t** | 這是無符號整數類型,它是 **sizeof** 關鍵字的結果。 |
| **wchar_t** | 這是一個寬字符常量大小的整數類型。 |
| **div_t** | 這是 **div** 函數返回的結構。 |
| **ldiv_t** | 這是 **ldiv** 函數返回的結構。 |
## 庫宏
下面是頭文件 stdlib.h 中定義的宏:
| 宏 | 描述 |
| --- | --- |
| **NULL** | 這個宏是一個空指針常量的值。 |
| **EXIT_FAILURE** | 這是 exit 函數失敗時要返回的值。 |
| **EXIT_SUCCESS** | 這是 exit 函數成功時要返回的值。 |
| **RAND_MAX** | 這個宏是 rand 函數返回的最大值。 |
| **MB_CUR_MAX** | 這個宏表示在多字節字符集中的最大字符數,不能大于 MB_LEN_MAX。 |
## 庫函數
下面是頭文件 stdlib.h 中定義的函數:
| 函數 | 描述 |
| --- | --- |
| [double atof(const char \*str)](c-function-atof.html) | 把參數 _str_ 所指向的字符串轉換為一個浮點數(類型為 double 型)。 |
| [int atoi(const char \*str)](c-function-atoi.html) | 把參數 _str_ 所指向的字符串轉換為一個整數(類型為 int 型)。 |
| [long int atol(const char \*str)](c-function-atol.html) | 把參數 _str_ 所指向的字符串轉換為一個長整數(類型為 long int 型)。 |
| [double strtod(const char \*str, char \*\*endptr)](c-function-strtod.html) | 把參數 _str_ 所指向的字符串轉換為一個浮點數(類型為 double 型)。 |
| [long int strtol(const char \*str, char \*\*endptr, int base)](c-function-strtol.html) | 把參數 _str_ 所指向的字符串轉換為一個長整數(類型為 long int 型)。 |
| [unsigned long int strtoul(const char \*str, char \*\*endptr, int base)](c-function-strtoul.html) | 把參數 _str_ 所指向的字符串轉換為一個無符號長整數(類型為 unsigned long int 型)。 |
| [void \*calloc(size_t nitems, size_t size)](c-function-calloc.html) | 分配所需的內存空間,并返回一個指向它的指針。 |
| [void free(void \*ptr](c-function-free.html) | 釋放之前調用 _calloc、malloc_ 或 _realloc_ 所分配的內存空間。 |
| [void \*malloc(size_t size)](c-function-malloc.html) | 分配所需的內存空間,并返回一個指向它的指針。 |
| [void \*realloc(void \*ptr, size_t size)](c-function-realloc.html) | 嘗試重新調整之前調用 _malloc_ or _calloc_ 所分配的 ptr 所指向的內存塊的大小。 |
| [void abort(void)](c-function-abort.html) | 使一個異常程序終止。 |
| [int atexit(void (\*func)(void))](c-function-atexit.html) | 當程序正常終止時,調用指定的函數 \*\*func\*\*。 |
| [void exit(int status)](c-function-exit.html) | 是程序正常終止。 |
| [char \*getenv(const char \*name)](c-function-getenv.html) | 搜索 name 所指向的環境字符串,并返回相關的值給字符串。 |
| [int system(const char \*string)](c-function-system.html) | 由 string 指定的命令傳給要被命令處理器執行的主機環境。 |
| [void \*bsearch(const void \*key, const void \*base, size_t nitems, size_t size, int (\*compar)(const void \*, const void \*))](c-function-bsearch.html) | 執行二進制搜索。 |
| [void qsort(void \*base, size_t nitems, size_t size, int (\*compar)(const void \*, const void\*))](c-function-qsort.html) | 數組排序。 |
| [int abs(int x)](c-function-abs.html) | 返回 x 的絕對值。 |
| [div_t div(int numer, int denom)](c-function-div.html) | 分子除以分母。 |
| [long int labs(long int x)](c-function-labs.html) | 返回 x 的絕對值。 |
| [ldiv_t ldiv(long int numer, long int denom)](c-function-ldiv.html) | 分子除以分母。 |
| [int rand(void)](c-function-rand.html) | 返回一個范圍在 0 到 _RAND_MAX_ 之間的偽隨機數。 |
| [void srand(unsigned int seed)](c-function-srand.html) | 該函數播種由函數 \*\*rand\*\* 使用的隨機數發生器。 |
| [int mblen(const char \*str, size_t n)](c-function-mblen.html) | 返回參數 _str_ 所指向的多字節字符的長度。 |
| [size_t mbstowcs(schar_t \*pwcs, const char \*str, size_t n)](c-function-mbstowcs.html) | 把參數 _str_ 所指向的多字節字符的字符串轉換為參數 _pwcs_ 所指向的數組。 |
| [int mbtowc(whcar_t \*pwc, const char \*str, size_t n)](c-function-mbtowc.html) | 檢查參數 _str_ 所指向的多字節字符。 |
| [size_t wcstombs(char \*str, const wchar_t \*pwcs, size_t n)](c-function-wcstombs.html) | 把數組 _pwcs_ 中存儲的編碼轉換為多字節字符,并把它們存儲在字符串 _str_ 中。 |
| [int wctomb(char \*str, wchar_t wchar)](c-function-wctomb.html) | 檢查對應于參數 _wchar_ 所給出的多字節字符的編碼。 |
- C語言教程
- C 簡介
- C 環境設置
- C 程序結構
- C 基本語法
- C 數據類型
- C 變量
- C 常量
- C 存儲類
- C 運算符
- C 判斷
- C 循環
- C 函數
- C 作用域規則
- C 數組
- C 指針
- C 字符串
- C 結構體
- C 共用體
- C 位域
- C typedef
- C 輸入 & 輸出
- C 文件讀寫
- C 預處理器
- C 頭文件
- C 強制類型轉換
- C 錯誤處理
- C 遞歸
- C 可變參數
- C 內存管理
- C 命令行參數
- C語言參考
- C 標準庫 - <assert.h>
- C 庫宏 - assert()
- C 標準庫 - <ctype.h>
- C 庫函數 - isalnum()
- C 庫函數 - isalpha()
- C 庫函數 - iscntrl()
- C 庫函數 - isdigit()
- C 庫函數 - isgraph()
- C 庫函數 - islower()
- C 庫函數 - isprint()
- C 庫函數 - ispunct()
- C 庫函數 - isspace()
- C 庫函數 - isupper()
- C 庫函數 - isxdigit()
- C 標準庫 - <errno.h>
- C 庫宏 - errno
- C 庫宏 - EDOM
- C 庫宏 - ERANGE
- C 標準庫 - <float.h>
- C 標準庫 - <limits.h>
- C 標準庫 - <locale.h>
- C 庫函數 - setlocale()
- C 庫函數 - localeconv()
- C 標準庫 - <math.h>
- C 庫函數 - acos()
- C 庫函數 - asin()
- C 庫函數 - atan()
- C 庫函數 - atan2()
- C 庫函數 - cos()
- C 庫函數 - cosh()
- C 庫函數 - sin()
- C 庫函數 - sinh()
- C 庫函數 - tanh()
- C 庫函數 - exp()
- C 庫函數 - frexp()
- C 庫函數 - ldexp()
- C 庫函數 - log()
- C 庫函數 - log10()
- C 庫函數 - modf()
- C 庫函數 - pow()
- C 庫函數 - sqrt()
- C 庫函數 - ceil()
- C 庫函數 - fabs()
- C 庫函數 - floor()
- C 庫函數 - fmod()
- C 標準庫 - <setjmp.h>
- C 庫宏 - setjmp()
- C 庫函數 - longjmp()
- C 標準庫 - <signal.h>
- C 庫函數 - signal()
- C 庫函數 - raise()
- C 標準庫 - <stdarg.h>
- C 庫宏 - va_start()
- C 庫宏 - va_arg()
- C 庫宏 - va_end()
- C 標準庫 - <stddef.h>
- C 庫宏 - NULL
- C 庫宏 - offsetof()
- C 標準庫 - <stdio.h>
- C 庫函數 - fclose()
- C 庫函數 - clearerr()
- C 庫函數 - feof()
- C 庫函數 - ferror()
- C 庫函數 - fflush()
- C 庫函數 - fgetpos()
- C 庫函數 - fopen()
- C 庫函數 - fread()
- C 庫函數 - freopen()
- C 庫函數 - fseek()
- C 庫函數 - fsetpos()
- C 庫函數 - ftell()
- C 庫函數 - fwrite()
- C 庫函數 - remove()
- C 庫函數 - rename()
- C 庫函數 - rewind()
- C 庫函數 - setbuf()
- C 庫函數 - tmpfile()
- C 庫函數 - tmpnam()
- C 庫函數 - fprintf()
- C 庫函數 - printf()
- C 庫函數 - sprintf()
- C 庫函數 - vfprintf()
- C 庫函數 - vprintf()
- C 庫函數 - vsprintf()
- C 庫函數 - fscanf()
- C 庫函數 - scanf()
- C 庫函數 - sscanf()
- C 庫函數 - fgetc()
- C 庫函數 - fgets()
- C 庫函數 - fputc()
- C 庫函數 - fputs()
- C 庫函數 - getc()
- C 庫函數 - getchar()
- C 庫函數 - gets()
- C 庫函數 - putc()
- C 庫函數 - putchar()
- C 庫函數 - puts()
- C 庫函數 - ungetc()
- C 庫函數 - perror()
- C 標準庫 - <stdlib.h>
- C 庫函數 - atof()
- C 庫函數 - atoi()
- C 庫函數 - atol()
- C 庫函數 - strtod()
- C 庫函數 - strtol()
- C 庫函數 - strtoul()
- C 庫函數 - calloc()
- C 庫函數 - free()
- C 庫函數 - malloc()
- C 庫函數 - realloc()
- C 庫函數 - abort()
- C 庫函數 - atexit()
- C 庫函數 - exit()
- C 庫函數 - getenv()
- C 庫函數 - system()
- C 庫函數 - bsearch()
- C 庫函數 - qsort()
- C 庫函數 - abs()
- C 庫函數 - div()
- C 庫函數 - labs()
- C 庫函數 - ldiv()
- C 庫函數 - rand()
- C 庫函數 - srand()
- C 庫函數 - mblen()
- C 庫函數 - mbstowcs()
- C 庫函數 - mbtowc()
- C 庫函數 - wcstombs()
- C 庫函數 - wctomb()
- C 標準庫 - <string.h>
- C 庫函數 - memchr()
- C 庫函數 - memcmp()
- C 庫函數 - memcpy()
- C 庫函數 - memmove()
- C 庫函數 - memset()
- C 庫函數 - strcat()
- C 庫函數 - strncat()
- C 庫函數 - strchr()
- C 庫函數 - strcmp()
- C 庫函數 - strncmp()
- C 庫函數 - strcoll()
- C 庫函數 - strcpy()
- C 庫函數 - strncpy()
- C 庫函數 - strcspn()
- C 庫函數 - strerror()
- C 庫函數 - strlen()
- C 庫函數 - strpbrk()
- C 庫函數 - strrchr()
- C 庫函數 - strspn()
- C 庫函數 - strstr()
- C 庫函數 - strtok()
- C 庫函數 - strxfrm()
- C 標準庫 - <time.h>
- C 庫函數 - asctime()
- C 庫函數 - clock()
- C 庫函數 - ctime()
- C 庫函數 - difftime()
- C 庫函數 - gmtime()
- C 庫函數 - localtime()
- C 庫函數 - mktime()
- C 庫函數 - strftime()
- C 庫函數 - time()
- 免責聲明