stdlib.h in C
stdlib.h in C
The header file named stdlib.h in Standard C Library defines four variable types, a number of macros and various functions to implement common features.
The variables are defined in stdlib.h
The following lists some types of variables defined in stdlib.h:
Description variable size_tThis is an unsigned integer type and the result of the sizeof keyword
wchar_tThis is an integer type whose size is a constant wide char
div_tThis is the structure returned by the div function
ldiv_tThis is the structure returned by the ldiv function
The macros are defined in stdlib.h
The table below lists some macros defined in stdlib.h:
Macro Description NULLThis macro is the value of a null pointer constant
EXIT_FAILUREThis is the value for exit function to return in case of failure
EXIT_SUCCESSThis is the value for exit function to return in case of success
RAND_MAXThis macro is the maximum value returned by the rand function
MB_CUR_MAXThis macro is the maximum number of bytes in a multi-byte character set that cannot be larger than MB_LEN_MAX
Functions are defined in stdlib.h
Here are some functions defined in stdio.h:
STD & Description1Double atof function (const char * str)
Convert a string pointed to by parameter str to a floating point number (type double)
2Int atoi function (const char * str)
Convert a string pointed to by parameter str to an integer (type int)
3Function long int atol (const char * str)
Convert a string pointed to by parameter str to some long int
4Function double strtod (const char * str, char ** endptr)
Convert a string pointed to by parameter str to a floating point number (type double)
5Function long int strtol (const char * str, char ** endptr, int base)
Convert a string pointed to by parameter str to some long int
6Function unsigned long int strtoul (const char * str, char ** endptr, int base)
Converts a string pointed to by parameter str to an unsigned number long int
7Function void * calloc (size_t nitems, size_t size)
Memory allocation is required and returns a pointer to it
8Void free function (void * ptr
Free the previously allocated memory by a call to calloc, malloc, or realloc
9Function void * malloc (size_t size)
Memory allocation is required and returns a pointer to it
tenVoid * realloc function (void * ptr, size_t size)
Attempt to recover the memory block pointed to by str that was previously allocated with a call to malloc or calloc
11Void abort function (void)
Causing an abnormal program end
twelfthInt atexit function (void (* func) (void))
Make the func function given to be called when the program ends in the usual way
13Function void exit (int status)
Make the program end normally
14Char * getenv function (const char * name)
Search for the environment string pointed to by name and return the value associated with that string
15Function int system (const char * string)
The command specified by the string is passed to the host environment to be executed by the Command Processor
16Void function * bsearch (const void * key, const void * base, size_t nitems, size_t size, int (* compar) (const void *, const void *))
Make a Binary Search
17Void qsort function (void * base, size_t nitems, size_t size, int (* compar) (const void *, const void *))
Arrange an array
18Int abs function (int x)
Returns the absolute value of x
19Div_t div function (int numer, int denom)
Divide the numerator numer to the demon number
20Function long int labs (long int x)
Returns the absolute value of x
21Ldiv_t ldiv function (long int numer, long int denom)
Divide the numerator numer to the demon number
22Function int rand (void)
Returns a random number in the range of values from 0 to RAND_MAX
23Function void srand (unsigned int seed)
This function provides seed for the random number generator used by the rand function
24Function int mblen (const char * str, size_t n)
Returns the length of a multi-byte char pointed to by parameter str
25Function size_t mbstowcs (schar_t * pwcs, const char * str, size_t n)
Convert the string of multi-byte char points pointed to by the parameter str to the array pointed to by pwcs
26Function int mbtowc (whcar_t * pwc, const char * str, size_t n)
Convert a multi-byte sequence into a wide char
27Function size_t wcstombs (char * str, const wchar_t * pwcs, size_t n)
Convert the code stored in the pwcs array into multi-byte char and store them in the string str
28Int wctomb function (char * str, wchar_t wchar)
Convert its wide char to a multi-byte char representation and store it at the beginning of the character array pointed to by str
According to Tutorialspoint
Previous lesson: Function of perror () in C
Next lesson: Atof () function in C
You should read it
Maybe you are interested
How to turn a photo into a painting using the Generative Fill function in Photoshop
How to use the TREND function in Excel
Google Sheets Functions to Simplify Your Budget Spreadsheets
Instructions for using the TRIMRANGE function to clean up Excel tables
How to master numerical data in Google Sheets with the AVERAGE function
Don't buy headphones if they lack this important function!