strtoul(3) CLIX strtoul(3)
NAME
strtoul - Converts a string to a long integer
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
unsigned long strtoul(
char *str ,
char **ptr ,
int base );
PARAMETERS
str A pointer to a character string
ptr A pointer to the first character in str not converted
base An integer representing the base of the resulting number
DESCRIPTION
The strtoul() function returns, as an unsigned long integer, the value
represented by the character string pointed to by str. The string is
scanned up to the first character that is inconsistent with the base. The
leading white space characters (as defined in isspace(3)) are ignored.
If the value of ptr is not (char **)NULL a pointer to the character
terminating the scan is returned in the location pointed to by ptr. If no
unsigned integer can be formed, that location is set to str, and zero is
returned.
If base is positive and not greater than 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 zero, the string itself determines the base as follows: after
an optional leading sign, a leading zero indicates octal conversion; a
leading 0x or 0X indicates hexadecimal conversion. Otherwise, decimal
conversion is used.
EXAMPLES
To return the unsigned long and integer values of a string:
foo (string)
char* string;
{
2/94 - Intergraph Corporation 1
strtoul(3) CLIX strtoul(3)
unsigned long L;
int I;
L = strtoul(string, (char**)0, 10);
I = atoi (string);
}
RETURN VALUES
If a correct value causes overflow, ULONG_MAX (as defined in <limits.h>)
is returned, and errno is set to ERANGE.
Otherwise, the unsigned long integer representation of str is returned.
ERRORS
[ERANGE] The correct value results in either an overflow or underflow.
RELATED INFORMATION
Functions: atoi(3), atof(3), atol(3), isspace(3), ctype(3), scanf(3),
strtod(3), strtol(3)
2 Intergraph Corporation - 2/94