strtoimax.3c (2010 09)
s
strtoimax(3C) strtoimax(3C)
NAME
strtoimax( ), strtoumax( ) - convert string to integer
SYNOPSIS
#include <inttypes.h>
intmax_t strtoimax(const char *__restrict str, char **__restrict ptr, int
base);
uintmax_t strtoumax(const char *__restrict str, char **__restrict ptr, int
base);
DESCRIPTION
strtoimax() or strtoumax() converts the character string pointed to by str to
intmax_t or
uintmax_t representation, respectively. The string is scanned up to the first character inconsistent
with the base. Leading ‘‘white-space’’ characters (as defined by
isspace() in ctype (3C)) are ignored. If
no conversion can take place, zero is returned.
If base is greater than or equal to 2 and less than or equal to 36, it is used as the base for conversion.
After an optional leading sign, leading zeros are ignored, and
0x or 0X is ignored if base is 16.
If base is zero, the string itself determines the base as follows: after an optional leading sign, a leading
zero indicates octal conversion; a leading
0x or 0X indicates hexadecimal conversion. Otherwise, decimal
conversion is used.
If the value of ptr is not
(char **)NULL, a pointer to the character terminating the scan is returned in
the location pointed to by ptr . If no integer can be formed, the location pointed to by ptr is set to str , and
zero is returned.
RETURN VALUE
Upon successful completion, all functions return the converted value, if any.
If the correct value would cause overflow:
strtoimax() returns INTMAX_MAX or INTMAX_MIN (according to the sign of the value), and
sets errno to [ERANGE],
strtoumax() returns UINTMAX_MAX and sets errno to [ERANGE].
For all other errors, zero is returned and
errno is set to indicate the error.
ERRORS
strtoimax() and strtoumax() fail and errno is set, if any of the following conditions are encoun-
tered:
[EINVAL] The value of base is not supported.
[ERANGE] The value to be returned would have caused overflow.
AUTHOR
strtoimax() and strtoumax() were developed by HP.
SEE ALSO
ctype(3C), strtod(3C), strtol(3C), scanf(3S), thread_safety(5).
STANDARDS CONFORMANCE
strtoimax(): C99
strtoumax(): C99
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1