strtoul(), strtoull(), strtoumax(), strtouq(), strtoul_l(), strtoull_l(), strtoumax_l()

convert a string to various unsigned integal types 

Function


SYNOPSIS

#include <stdlib.h>

unsigned long strtoul(const char *nptr, char **endptr, int base);

unsigned long long strtoul(const char *nptr, char **endptr, int base);

uintmax_t strtoumax(const char *nptr, char **endptr, int base);

uquad_t strtouq(const char *nptr, char **endptr, int base);

unsigned long strtoul_l(const char *nptr, char **endptr, int base, locale_t locale);

unsigned long long strtoull_l(const char *nptr, char **endptr, int base, locale_t locale);

#include <inttypes.h>

uintmax_t strtoumax(const char *nptr, char **endptr, int base);

uintmax_t strtoumax_l(const char *nptr, char **endptr, int base, locale_t locale);


DESCRIPTION

The strtoul() class of functions convert the string pointed to by nptr into unsigned long, unsigned long long, uquad_t or uintmax_t. by nptr to an unsigned long int representation. This function recognizes (in order) an optional string of spaces, an optional base indicator (0 for octal, X or x for hexadecimal), and a string of digits. The first unrecognized character ends the string. A pointer to this unrecognized character is stored in the object addressed by endptr, if endptr is not NULL.

If base is non-zero, its value determines the set of recognized digits and also overrides the optional base indicator character. If base is zero, nptr is assumed to be base 10, unless an optional base indicator character is given.


PARAMETERS

nptr 

Points to a character string for strtoul() to convert.

endptr 

Is a result parameter that, if not NULL, is loaded with the address of the first character that strtoul() does not attempt to convert.

base 

Is the base of the string, a value between 0 and 36.

locale 

Is a locale_t perhaps returned by newlocale() or LC_GLOBAL_LOCALE or 0 for the current thread locale set with uselocale().


RETURN VALUES

The strtoul() class of functions return the converted value, if there is any. If no conversion was performed, the functions return a value of zero. If the converted value overflows, strtoul() returns ULONG_MAX, ULONGLONG_MAX, UQUAD_MAX or UINTMAX_MAX and sets errno to ERANGE.

strtoul_l(), strtoull_l(), qnd strtoumax_l() behave in the same way as strtoul(), strtoull() and strtoumax() without the _l suffix, but use the specified locale rather than the global or per-thread locale. A locale_t is returned by newlocale().


CONFORMANCE

strtoul(), strtoull() and strtoumax() conform to ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
atoi(), atol(), newlocale(), setlocale(), strtod(), strtod_l(), strtof(), strtof_l(), strtoimax(), strtoimax_l(), strtol(), strtol_l(), strtold(), strtold_l(), strtoll(), strtoll_l(), strtoq()


PTC MKS Toolkit 10.4 Documentation Build 39.