a2u(3)

Name
a2u, a2uhh, a2uh, a2ui, a2ul, a2ull - convert a string to an unsigned integer

Library
String-to-integer library (liba2i, -la2i)

Synopsis
#include <a2i/a2i/a2u.h>

  Type-generic macro
int
a2u( TYPE, TYPE *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
TYPE min, TYPE max);

  const-generic functions
int
a2uhh( unsigned char *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
unsigned char min, unsigned char max);
int
a2uh( unsigned short *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
unsigned short min, unsigned short max);
int
a2ui( unsigned int *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
unsigned int min, unsigned int max);
int
a2ul( unsigned long *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
unsigned long min, unsigned long max);
int
a2ull( unsigned long long *restrict n, QChar *s,
QChar **_Nullable restrict endp, int base,
unsigned long long min, unsigned long long max);

Description
These functions and macros are the unsigned counterparts of a2s(3).

These reject negative values, instead of silently wrapping them around (both strtoul(3) and strtou(3bsd) wrap around negative values before checking for overflow).

Examples
    if (a2u(useconds_t, &us, s, NULL, 10, 0, 1000000) == -1)
    	goto err;

See also
a2i(3), a2s(3), str2i(3), str2s(3), str2u(3), atof(3), atoi(3), strtod(3), strtoumax(3), strtoul(3), strtou(3)