The header <stdlib.h> declares four types and several functions of general utility, and defines several macros.
The types declared are size_t and wchar_t (both described in the ANSI specification section 7.1.6),
div_t
which is a structure type that is the type of the value returned by the div function, and
ldiv_t
which is a structure type that is the type of the value returned by the ldiv function.
The macros defined are NULL (described in in the ANSI specification section 7.1.6),
EXIT_FAILURE
and
EXIT_SUCCESS, which expand to integral expressions that may be used as the argument to the exit function to return unsuccessful or successful termination status respectively, to the host environment,
RAND_MAX which expands to an integral constant expression, the value of which is the maximum value returned by the rand function, and
MB_CUR_MAX which expands to a positive integer expression whose value is the maximum number of bytes in a multi-byte character for the extended character set specified by the current locale (category LC_TYPE), and whose value is never greater than MB_LEN_MAX
#include <stdlib.h>
double
atof
(const char *
iptr );
The atof function converts the initial portion of the string pointed to by iptr to double. Except for the behavior on error, it is equivalent to
strtod (nptr, (char **)NULL)
The atof function returns the converted value as a double length floating point number.
#include <stdlib.h>
int
atoi
(const char *
nptr );
The atoi function converts the initial portion of the string pointed to by nptr to int representation. Except for the behavior in error, it is equivalent to
(int)strtol (nptr, (char **)NULL, 10)
The atoi function returns the converted value.
#include <stdlib.h>
long
atol
(const char *
nptr );
The atol function converts the initial portion of the string pointed to by nptr to long int representation. Except for the behavior in error, it is equivalent to
strtol (nptr, (char **)NULL, 10)
The atol function returns the converted value.
#include <stdlib.h>
double
strtod
(const char *
nptr , char **
endptr );
The strtod function converts the initial portion of the string pointed to by nptr to double representation. First it decomposes the string into three parts: an initial, possibly empty, sequence of white space characters (as specified by the isspace function), a subject sequence resembling a floating point constant: and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then it attempts to convert the subject sequence to a floating point number, and return the result.
The expected form of the subject sequence is an optional plus or minus sign, then a non-empty sequence of digits optionally containing a decimal-point character, then an optional exponent part as defined in the ANSI specification section 6.1.3.1, but no floating suffix. The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists of entirely white space, or if the first non-white space character is other than a sign, a digit or a decimal point.
The strtod function returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, plus of minus HUGE_VAL is returned (according to the sign of the value), and the value of the macros ERANGE is stored in errno. If the correct value would cause underflow, zero is returned and the value of the macro ERANGE is store in errno.
In GCC-1750, the accuracy of the result is generally better than 10 digits. In most cases, 13 decimal digits is sufficient to represent any of the 2**48 values of the M1750 extended precision floating point format. Powers of 10 within the range of the M1750 extended precision format (roughly 1.0e-38 to 1.0e+38) are converted exactly.
#include <stdlib.h>
long
strtol
(const char *
nptr , char **
endptr , int base
);
The strtol function converts the initial portion of the string pointed to by nptr to long int representation. First it decomposes the input string into three parts: an initial, possibly empty, sequence of white space characters (as specified by the The isspace function Section 3.1.9), a subject sequence resembling an integer represented in some radix determined by the value of base, and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then it attempts to convert the subject sequence to an integer, and returns the result.
The strtol function returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, LONG_MAX or LONG_MIN is returned (according to the sign of the value), and the value of the macro ERANGE is is stored in errno.
#include <stdlib.h>
unsigned long strtoul
(const char * nptr , char **
endptr , int base
);
The strtoul function converts the initial portion of the string pointed to by nptr to unsigned long int representation. First it decomposes the input string into three parts: an initial, possibly empty, sequence of white space characters (as specified by the Section 3.1.9, a subject sequence resembling an unsigned integer represented in some radix determined by the value of base, and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then it attempts to convert the subject sequence to an unsigned integer, and returns the result.
The strtoul function returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, ULONG_MAX is returned, and the value of the macro ERANGE is is stored in errno.