Guardian C Library Calls Reference Manual
strtoul
3-214 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
strtoul
The strtoul function converts a string of characters to an unsigned long int value using a
specified base.
str_ptr
points to the string to convert.
end_ptr_ptr
points to the variable of type pointer to char where strtoul stores a pointer to the first
unrecognized character in *str_ptr.
base
specifies the base of the long integer. It can be in the range from 0 to 36. If base is
zero, strtoul scans for a valid integer constant, optionally preceded by a sign but
without a suffix.
If base is less than 0, equal to 1, or greater than 36, strtoul does not process the input
string. It returns zero and sets end_ptr_ptr to &str_ptr.
For bases greater than 10, strtoul interprets the characters a through z (and A
through Z) as digits representing the values 10 through 35.
Return Value
is the converted unsigned long value if the conversion is successful. If strtoul could
perform no conversion, it returns zero. If the correctly converted value would cause
overflow, strtoul returns ULONG_MAX and sets errno to ERANGE (a range error).
Usage Guidelines
•
The strtoul function skips all leading space characters (as defined by isspace) in
*str_ptr.
•
The strtoul function halts scanning when it encounters an unrecognized character.
#include <stdlibh>
unsigned long strtoul(const char *str_ptr, char
**end_ptr_ptr,
int base);