May 11, 2021 C
The stdlib .h header file defines four variable types, some macros, and various common tool functions.
Here are the types of variables defined in the header file stdlib.h:
Serial number | Variable & description |
---|---|
1 |
size_t
This is an unsigned integer type, it is sizeof The result of the keyword. |
2 |
wchar_t
This is an integer type of a wide-character constant size. |
3 |
div_t
This is div The structure returned by the function. |
4 |
ldiv_t
This is ldiv The structure returned by the function. |
Here are the macros defined in the header file stdlib.h:
Serial number | Macro & Description |
---|---|
1 |
NULL
This macro is a value of an empty pointer. |
2 |
EXIT_FAILURE
This is the value to return when the EXIT function fails. |
3 |
EXIT_SUCCESS
This is the value to return when the exit function is successful. |
4 |
RAND_MAX
This macro is the maximum value returned by the RAND function. |
5 |
MB_CUR_MAX
This macro indicates the maximum number of characters in the multi-byte character set, cannot be greater than MB_LEN_MAX. |
Here are the functions defined in the header file stdlib.h:
Serial number | Function & Description |
---|---|
1 |
double atof(const char *str)
Put parameters str The polar string pointed to a floating point (type Double). |
2 |
int atoi(const char *str)
Put parameters str The pointer to the string is converted to an integer (type INT type). |
3 |
long int atol(const char *str)
Put parameters str The polar string pointed to the string is converted to a long integer (type Long INT). |
4 |
double strtod(const char *str, char **endptr)
Put parameters str The polar string pointed to a floating point (type Double). |
5 |
long int strtol(const char *str, char **endptr, int base)
Put parameters str The polar string pointed to the string is converted to a long integer (type Long INT). |
6 |
unsigned long int strtoul(const char *str, char **endptr, int base)
Put parameters str The polar string pointed to a symbolic long integer (type UNSigned long int type). |
7 |
void *calloc(size_t nitems, size_t size)
Assign the required memory space and return a pointer to it. |
8 |
void free(void *ptr)
Before released calloc、malloc or realloc Allocated memory space. |
9 |
void *malloc(size_t size)
Assign the required memory space and return a pointer to it. |
10 |
void *realloc(void *ptr, size_t size)
Try to call before calling malloc or calloc The size of the memory pointer to the allocated PTR. |
11 |
void abort(void)
Terminate an exception program. |
12 |
int atexit(void (*func)(void))
When the program is terminated normally, call the specified function. func 。 |
13 |
void exit(int status)
Make the program normally terminate. |
14 |
char *getenv(const char *name)
Search for the environment string points to Name and return the relevant value to the string. |
15 |
int system(const char *string)
The command specified by the string is transmitted to the host environment to be executed by the command processor. |
16 |
void *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *))
Execute two points. |
17 |
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))
Array sort. |
18 |
int abs(int x)
Returns the absolute value of X. |
19 |
div_t div(int numer, int denom)
The molecule is divided by a denominator. |
20 |
long int labs(long int x)
Returns the absolute value of X. |
21 |
ldiv_t ldiv(long int numer, long int denom)
The molecule is divided by a denominator. |
22 |
int rand(void)
Returns a range of 0 to 0 RAND_MAX The pseudo random number is between. |
23 |
void srand(unsigned int seed)
This function is planted by a function rand Random number generator used. |
24 |
int mblen(const char *str, size_t n)
Return parameters str The length of the multi-byte character pointed to. |
25 |
size_t mbstowcs(schar_t *pwcs, const char *str, size_t n)
Put parameters str The string of string pointed to the multi-byte character is converted to parameters. pwcs Array pointed to. |
26 |
int mbtowc(whcar_t *pwc, const char *str, size_t n)
Inspection parameters str The multi-byte character pointed to. |
27 |
size_t wcstombs(char *str, const wchar_t *pwcs, size_t n)
Array pwcs The encoding in the stored coding is converted to multi-byte characters and store them in a string. str middle. |
28 |
int wctomb(char *str, wchar_t wchar)
Check corresponding to parameters wchar The encoded multibyte character given. |