stdlib.h

Overview

Related Modules:

UTILS

Description:

Declares common functions used for performing I/O operations.

You can use the functions provided in this file to complete string conversion, random number generation, array sorting, and tree-related operations during development.

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name Description
div_t Defines the structures of the division operation result.
ldiv_t Defines the structures of the division operation result.
lldiv_t Defines the structures of the division operation result.

Functions

Function Name Description
atoi (const char nptr) int Converts an input string to an integer.
atol (const char nptr) long Converts an input string to a long integer.
atoll (const char nptr) long long Converts a string to an 8-byte long integer.
atof (const char nptr) double Converts an input string to a double-precision floating-point number.
strtof (const char nptr, char **endptr) float Converts an input string to a floating-point number.
strtod (const char nptr, char endptr) double Converts a string to double.
strtold (const char *nptr, char endptr) long double Converts a string to long double.
strtol (const char nptr, char **endptr, int base) long Converts a string to a long integer according to the given base.
strtoul (const char nptr, char endptr, int base) unsigned long Converts a string to an unsigned long integer according to the given base.
strtoll (const char *nptr, char endptr, int base) long long Converts a string to a long long integer according to the given base.
strtoull (const char nptr, char **endptr, int base) unsigned long long Converts a string to an unsigned long long integer according to the given base.
rand (void) int Generates a pseudo-random number.
srand (unsigned int seed) void Initializes a random number generator.
malloc (size_t size) void Dynamically allocates a memory block of size.
calloc (size_t nmemb, size_t size) void Dynamically allocates nmemb memory blocks of size.
realloc (void ptr, size_t size) void Changes the size of the memory block pointed to by ptr to size bytes.
free (void ptr) void Releases the memory space pointed to by ptr.
abort (void) _Noreturn void Terminates an abnormal process and sends the SIGABRT signal to the caller.
atexit (void(func)(void)) int Registers a termination function.
exit (int status) void Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process. All functions registered with atexit and on_exit are called in the reverse order.
getenv (const char name) char Obtains the value of an environment variable.
_Exit (int status) void Terminates the calling process, clears the used memory space and various data structures in the kernel, and sends the process end status to the parent process.
assert (scalar expression) void Aborts the program if assertion is false.
secure_getenv (const char name) char Obtains the value of an environment variable.
bsearch (const void key, const void base, size_t nel, size_t width, int(compar)(const void , const void )) void Searches for key using the binary search algorithm from the array element base[0] to base[num-1].
qsort (const void base, size_t nel, size_t width, int(compar)(const void , const void )) void Sorts array elements base[0] to base[num-1] based on the comparison rules of compar.
abs (int i) int Obtains the absolute value of an integer value.
labs (long i) long Calculates the absolute value of a long integer.
llabs (long long i) long long Calculates the absolute value of a long long integer.
div (int numerator, int denominator) div_t Calculates the quotient and remainder of an integer after division.
ldiv (long numerator, long denominator) ldiv_t Calculates the quotient and remainder of a long integer after division.
lldiv (long long numerator, long long denominator) lldiv_t Calculates the quotient and remainder of a long long integer after division.
mblen (const char s, size_t n) int Obtains the number of bytes in the next multi-byte string.
mbtowc (wchar_t pwc, const char s, size_t n) int Converts a string constant to a wide character.
wctomb (char s, wchar_t wc) int Converts a wide character to its multi-byte sequence and stores it in a character array.
mbstowcs (wchar_t dest, const char src, size_t n) size_t Converts a multi-byte string to a wide-character string.
wcstombs (char dest, const wchar_t src, size_t n) size_t Converts a wide-character string to a multi-byte string.
posix_memalign (void **memptr, size_t alignment, size_t size) int Allocates memory with the specified size based on the given alignment.
setenv (const char name, const char value, int overwrite) int Add or change an environment variable.
unsetenv (const char name) int Deletes an environment variable.
mkstemp (char template) int Creates and opens a unique temporary file.
mkostemp (char template, int flags) int Creates and opens a unique temporary file.
mkdtemp (char template) char Creates a unique temporary directory based on template.
getsubopt (char optionp, char const tokens, char valuep) int Processes the parameters of an option in the command line.
rand_r (unsigned seedp) int Generates a pseudo-random number.
realpath (const char restrict path, char *restrict resolved) char Obtains a normalized absolute path.
random (void) long int Generates a pseudo-random number.
srandom (unsigned int seed) void Initializes a random number generator.
initstate (unsigned int seed, char state, size_t n) char Initializes a random number generator.
setstate (char state) char Sets the current state list for subsequent random use.
putenv (char s) int Configures an environment variable.
unlockpt (int fd) int Unlocks the secondary pseudo terminal corresponding to a primary pseudo terminal.
ptsname (int fd) char Obtains the name of a pseudo terminal.
l64a (long value) char Converts a long integer to a 64-bit ASCII string.
a64l (const char str64) long Converts between a 32-bit long integer and a little-endian 64-bit ASCII string.
drand48 (void) double Obtains a random number.
erand48 (unsigned short xsubi[3]) double Obtains a random number.
lrand48 (void) long int Generates pseudo-random numbers evenly distributed between [0, 2^31).
nrand48 (unsigned short xsubi[3]) long int Generates pseudo-random numbers evenly distributed between [0, 2^31).
mrand48 (void) long Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).
jrand48 (unsigned short xsubi[3]) long Generates pseudo-random numbers evenly distributed between [-2^31, 2^31).
srand48 (long int seedval) void Sets the start seed value for the pseudo-random number generator.
seed48 (unsigned short[3]) unsigned short Generates an evenly distributed pseudo-random seed.
lcong48 (unsigned short param[7]) void Sets the seed and related algorithm parameters for the pseudo-random number generator.
mktemp (char template) char Creates a unique temporary file name.
mkstemps (char template, int suffixlen) int Creates and opens a unique temporary file.
mkostemps (char template, int suffixlen, int flags) int Creates and opens a unique temporary file.
valloc (size_t size) void Allocates memory with the specified size and aligns the allocated memory by page size.
ecvt (double number, int ndigits, int decpt, int sign) char Converts a double-precision floating-point number into a string.
fcvt (double number, int ndigits, int decpt, int sign) char Converts a floating-point number to a string.
gcvt (double x, int n, char b) char * Converts a floating-point number to a string.