HP C/iX Library Reference Manual (30026-90004)
356 Chapter5
HP C/iX Library Function Descriptions
strtoul
strtoul
Converts a string to an unsigned long int representation.
Syntax
#include <stdlib.h>
unsigned long int strtoul (const char
*str
,
char
**ptr
, int
base
);
Parameters
str
A pointer to a character string to be converted. If
base
is set to zero,
leading characters in
str
define the conversion. After an optional leading
sign, a leading zero indicates octal conversion, and a leading "0x" or "0X"
indicates hexadecimal conversion. Otherwise, decimal conversion is used.
ptr
If
ptr
is not NULL, a pointer to the character terminating the scan is stored
in the object pointed to by
ptr
.
base
If
base
is between 2 and 36, it is used as the base for conversion. After an
optional leading sign, leading zeros are ignored, and "0x" or "0X" is
ignored if
base
is 16. If
base
is set to zero, the string itself determines the
base
.
Return Values
≠0 A string value converted to a long integer.
0 When
*ptr
is set to
str
and a value of zero is returned, it indicates that no
number can be formed.
ULONG_MAX The conversion would cause an overflow; errno is set to ERANGE.
Description
The strtoul function returns as an unsigned long int the value represented by the
character string pointed to by
str
.
See Also
strtod(), strtol(), atof(), ANSI C 4.10.1.6