Utility Functions in C++
What are Utility functions in C++?
Explanation
The standard function has several
utility functions for number of conversions, variable-length, argument processing, sorting and searching, and random number generation. To use these function the header <cstdlib> is required.
This header defines the types "div_t", "ldiv_t", "size_t". Following table lists the macros supported by <cstdlib> header.
Following table lists macros supported by utility functions of C++ Standard function Library.
Macro | Description |
MB_CUR_MAX | Maximumlength in bytes of a multibyte character. |
NULL | A null pointer. |
RAND_MAX | Maximum value returned by the rand() function. |
EXIT_FAILURE | Value retruned to calling process if program is terminated unsuccessfully. |
EXIT_SUCCESS Value retruned to calling process if program is terminated successfully. |
The following table lists the important utility functions of C++ Standard Function Library.
Functions | Description |
abort | Terminates the program abnormally. |
abs | Returns the absolute value of the number. |
atof | Converts a string into a double value. |
atoi | Converts a string into a integer value. |
atol | Converts a string into a long value. |
bsearch | Performs a binary search on an array. |
div | Returns the numerator, denominator of an integer value and quotient, remainder for a long value. |
exit | Causes normal and immediate termination of a program. |
getenv | Returns a pointer to the environmental variable for the given argument. |
qsort | Function is used to quicksort an array. |
rand | Generates a random number. |
srand | Initializes a random number generation. |
Following table lists macros supported by utility functions of C++ Standard function Library.