DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

strtoul(S)


strtoul -- convert a string to an unsigned long integer

Syntax

cc . . . -lc

#include <stdlib.h>

unsigned long strtoul (const char *sptr, char **eptr, int base)

Description

The strtoul routine converts a string to an unsigned long integer. sptr points to the start of the string, eptr points to the end of the string, and base defines the input radix, for example, base 8 is octal. base can be in the range of a value of zero to 36.

If base is a value of zero, then the string is assumed to contain the key for the base. The string can start with plus (+) or minus (-), or without a sign. The next character, or the first if a sign is not specified, specifies the input radix. If zero (0), then decimal is assumed. If the character is either lowercase ``x'' or ``X'', then hexadecimal is assumed; otherwise, octal is assumed.

Return values

On success, an unsigned long integer value for the string is returned; otherwise, on overflow, errno is set to ERANGE and the value of the ULONG_MAX constant is returned.

If strtoul is give a base greater than 36 or less than 2, it returns 0 and sets errno to EINVAL.

See also

strtod(S), strtol(S)

Standards conformance

strtoul is an extension developed and maintained by The SCO Group. It is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and ANSI X3.159-1989 Programming Language -- C .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003