wcstoumax() — Convert a wide-character string to a intmax_t

Standards

Standards / Extensions C or C++ Dependencies

C99
Single UNIX Specification, Version 3
C++ TR1 C99

both z/OS® V1R7

Format

#define _ISOC99_SOURCE
#include <inttypes.h>

uintmax_t wcstoumax(const wchar_t * __restrict__ nptr, 
                    wchar_t ** __restrict__ endptr, int base);
Compile requirement: Function wcstoumax() requires long long to be available.

General description

The wcstoumax() function converts the wide-character string nptr to an uintmax_t integer type. Valid input values for base are 0 and in the range 2-36. The wcstoumax() function is equivalent to wcstoul() and wcstoull(). The only difference being that the return value is of type uintmax_t. See wcstoull() for more information.

Returned value

If successful, wcstoumax() returns the converted value, if any.

If unsuccessful, wcstoumax() returns 0 if no conversion could be performed. If the correct value is outside the range of representable values, wcstoumax() returns UINTMAX_MAX. If the value of base is not supported, wcstoumax() returns 0.

If unsuccessful wcstoumax() sets errno to one of the following values:

Error Code
Description
EINVAL
The value of base is not supported.
ERANGE
The conversion caused an overflow.

Example

#define _ISOC99_SOURCE
#include <inttypes.h>      
#include <stdio.h>        

 int main(void)                                       
{                                                    
   wchar_t *nptr;                                    
   wchar_t *endptr;                                  
   uintmax_t  j;                                      
   int base = 10;                                    
   nptr = L"10110134932";                            
   printf("nptr = `%ls`\n", nptr);                   
      j = wcstoumax(nptr, &endptr, base);            
      printf("wcstoumax = %ju\n", j);            
      printf("Stopped scan at `%ls`\n\n", endptr);
}    

Output

nptr = `10110134932`      
wcstoumax = 10110134932
Stopped scan at ``  

Related information