Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C99 |
both | z/OS® V1R7 |
#define _ISOC99_SOURCE
#include <inttypes.h>
uintmax_t strtoumax(const char * __restrict__ nptr,
char ** __restrict__ endptr, int base);
The strtoumax() function converts the string nptr to an uintmax_t integer type. Valid input values for base are 0 and in the range 2-36. The strtoumax() function is equivalent to strtoul() and strtoull(). The only difference being that the return value is of type uintmax_t. See strtoull for more information.
If successful, strtoumax() returns the converted uintmax_t value, represented in the string.
If unsuccessful, strtoumax() returns 0 if no conversion could be performed. If the correct value is outside the range of representable values, strtoumax() returns UINTMAX_MAX. If the value of base is not supported, strtoumax() returns 0.
If unsuccessful strtoumax() sets errno to one of the following values:
#define _ISOC99_SOURCE
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
uintmax_t j;
int base = 10;
char *nptr, *endptr;
nptr = "20690239864abc";
printf("string = %s\n", nptr);
j = strtoumax(nptr, &endptr, base);
printf("strtoumax = %ju (base %d)\n", j, base);
printf("Stopped scan at %s\n\n", endptr);
}
Output
string = 20690239864abc
strtoumax = 20690239864 (base 10)
Stopped scan at abc