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