C Standard Library - <stdlib.h>
Introduction
stdlib .h The header file defines four variable types, some macros and various general utility functions.
Library variables
The following are the variable types defined in the header file stdlib.h:
Serial number | Variables & Description |
---|---|
1 | size_t This is the unsigned integer type, which is the sizeof keyword result. |
2 | wchar_t This is a wide character constant-sized integer type. |
3 | div_t This is the structure returned by the div function. |
4 | ldiv_t This is the structure returned by the ldiv function. |
Library macros
The following are the macros defined in the header file stdlib.h:
Serial number | Macro & Description |
---|---|
1 | NULL This macro is the value of a null pointer constant. |
2 | EXIT_FAILURE This is the value to be returned when the exit function fails. |
3 | EXIT_SUCCESS This is the value to be returned when the exit function succeeds. |
4 | RAND_MAX This macro is the maximum value returned by the rand function. |
5 | MB_CUR_MAX This macro represents the maximum number of characters in the multi-byte character set, which cannot be greater than MB_LEN_MAX. |
Library functions
The following are the functions defined in the header file stdlib.h:
Serial number | Function & Description |
---|---|
1 | double atof(const char *str) Convert the string pointed to by the parameter str into a floating point number (type double). |
2 | int atoi(const char *str) Convert the string pointed to by the parameter str to an integer (type is of type int). |
3 | long int atol(const char *str) Convert the string pointed to by the parameter str into a long integer (The type is long int). |
4 | double strtod(const char *str, char **endptr) Convert the string pointed to by the parameter str It is a floating point number (type double). |
5 | long int strtol(const char *str, char **endptr, int base) Parameter str points 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 the parameters str The pointed-to string is converted to an unsigned long integer (type unsigned long int). |
7 | void *calloc(size_t nitems, size_t size) Allocate the required memory space and return a pointer to it. |
8 | void free(void *ptr) Calling calloc, malloc or realloc before releasing allocated memory space. |
9 | void *malloc(size_t size) Allocate the required memory space and return a pointer to it. |
10 | void *realloc(void *ptr, size_t size) Call malloc or calloc before trying to resize The size of the memory block pointed to by the allocated ptr. |
11 | void abort(void) Causes an abnormal program to terminate. |
12 | int atexit(void (*func)(void)) When the program terminates normally, call the specified functionfunc. |
13 | void exit(int status) Cause the program to terminate normally. |
14 | char *getenv(const char *name) Search for the environment string pointed to by name and return the relevant value to the string. |
15 | int system(const char *string) The command specified by string is passed 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 *)) Perform binary search. |
17 | void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) Array sorting. |
18 | int abs(int x) Returns the absolute value of x. |
19 | div_t div(int numer, int denom) Divide the numerator by the denominator. |
20 | long int labs(long int x) Returns the absolute value of x. |
21 | ldiv_t ldiv(long int numer, long int denom) Divide the numerator by the denominator. |
22 | int rand(void) Returns a pseudo-random number ranging from 0 to RAND_MAX. |
23 | void srand(unsigned int seed) This function seeds the random number generator used by function rand. |
24 | int mblen(const char *str, size_t n) Returns the multi-byte character pointed to by the parameter str length. |
25 | size_t mbstowcs(schar_t *pwcs, const char *str, size_t n) Change the number pointed to by the parameter str A string of byte characters is converted to the array pointed to by parameter pwcs. |
26 | int mbtowc(whcar_t *pwc, const char *str, size_t n) Check the parameter str points to Byte characters. |
27 | size_t wcstombs(char *str, const wchar_t *pwcs, size_t n) Put the encoding stored in the array pwcs Convert to multibyte characters and store them in the string str. |
28 | int wctomb(char *str, wchar_t wchar) Check the multibyte corresponding to the parameter wchar The encoding of the character. |