December 2005
Beginner to intermediate
618 pages
20h 19m
English
wcstoumax
Converts a wide string into an integer value with type
uintmax_t
#include <stddef.h> #include <inttypes.h> uintmax_twcstoumax( const wchar_t * restrictwcs, wchar_t ** restrictendptr, intbase);
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”).
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: ...
wcstoimax(), wcstol(), and wcstoul(); wcstod(), wcstof(), and wcstold(); strtoimax() and
strtoumax()
Read now
Unlock full access