Previous Page
Next Page

wcstoumax

Converts a wide string into an integer value with type uintmax_t

#include <stddef.h>
#include <inttypes.h>
uintmax_t wcstoumax ( const wchar_t * restrict wcs ,
                     wchar_t ** restrict endptr , int base  );

The wcstoumax( ) function is similar to wcstoul( ), except that it converts a wide string to an integer value of type uintmax_t. If the conversion fails, wcstoumax( ) returns 0. If the result of the conversion exceeds the range of the type uintmax_t, then the wcstoumax( ) returns UINTMAX_MAX and sets the errno variable to the value of ERANGE ("range error").

Example

typedef struct {
  uintmax_t packets, bytes;
  wchar_t   policy[16];
  wchar_t   protocol[6];
  /* ... */
} stats_t ;
stats_t iface_in;

wchar_t wcsstat[ ] =
                L"25183 1633438 ACCEPT tcp -- eth2 * 0.0.0.0/0 tcp dpts:80";
wchar_t *wcsptr = wcsstat;

iface_in.packets = wcstoumax( wcsptr, &wcsptr, 10 );
iface_in.bytes = wcstoumax( ++wcsptr, &wcsptr, 10 );
/* ... */
wprintf( L"Packets: %" PRIuMAX "; bytes: %" PRIuMAX "; policy: ...\n",
         iface_in.packets, iface_in.bytes );

This code produces the following output:

Packets: 25183; bytes: 1633438; policy: ...

See Also

wcstoimax( ), wcstol( ), and wcstoul( ); wcstod( ), wcstof( ), and wcstold( ); strtoimax( ) and strtoumax( )


Previous Page
Next Page