C C 學習記錄 標準庫標頭檔案stdlib h

2021-08-20 02:25:29 字數 1743 閱讀 2972

小結:1.    字串轉換,常見於主函式傳參,如 atoi;

2.    隨機函式,如 srand,rand;

3.    記憶體操作,如 malloc,free,但是注意!memset,memcpy等操作是在標頭檔案string.h中;

4.    環境介面,如 exit;

5.    abs();

以下是詳細:

1 字串轉換

double atof (const char*);

int atoi (const char*);

long atol (const char*);

double strtod (const char*, char**);

long strtol (const char*, char**, int);

unsigned long strtoul (const char*, char**, int);

2 隨機數

常量#define rand_max 0x7fff rand的最大返回值

函式void srand (unsigned int); 置隨機數發生器(種子)

int rand (void); 返回下乙個偽隨機數

3 記憶體管理

常量#define null ((void *)0) 空指標

函式void* calloc (size_t, size_t); 分配記憶體, 並清零

void* malloc (size_t); 分配記憶體

void* realloc (void*, size_t); 重新分配記憶體, 返回新指標

void free (void*); 釋放記憶體

4 與環境的介面

常量#define exit_success 0

#define exit_failure 1

函式void abort (void);

void exit (int);

int atexit (void (*)(void));

int system (const char*);

char* getenv (const char*);

5 查詢與排序

void* bsearch (const void*, const void*, size_t, size_t, 

int (*)(const void*, const void*));

void qsort (const void*, size_t, size_t,

int (*)(const void*, const void*));

6 整數運算

結構typedef struct div_t;

typedef struct ldiv_t;

函式int abs (int);

long labs (long);

div_t div (int, int);

ldiv_t ldiv (long, long);

7 多位元組字元

常量mb_cur_max 多位元組字元中的最大位元組數

函式size_t wcstombs (char*, const wchar_t*, size_t);

int wctomb (char*, wchar_t);

int mblen (const char*, size_t);

size_t mbstowcs (wchar_t*, const char*, size_t);

int mbtowc (wchar_t*, const char*, size_t);

C 標準庫標頭檔案

包含c 標準輸入和輸出函式的函式原型,並已取代了標頭檔案 格式化資料流的的流操縱元的函式原型,並以取代了標頭檔案 顧名思義,它包含各個數學函式原型,並已取代 它包含數轉換為文字,文字轉換為數,記憶體分配 隨機數 以及其他各種攻取函式的的函式原型並取代了標頭檔案 該標頭檔案包含維護時間和日期函式原型和...

標準庫標頭檔案 memory

unique ptr 模板類,擁有獨有物件所有權語義的智慧型指標 shared ptr 模板類,擁有共享物件所有權語義的智慧型指標,不會因為weak ptr也指向同乙個物件而引用計數加1 weak ptr 模板類,由shared ptr所管理的物件的弱引用,避免迴圈引用 auto ptr 模板類,c...

標準庫標頭檔案 cctype

int isalnum int ch 檢查字元是否為字母或數字 int isalpha int ch 檢查字元是否為字母 int islower int ch 檢查字元是否為小寫 int isupper int ch 檢查字元是否為大寫字元 int isdigit int ch 檢查字元是否為數字 ...