File:  [Research Unix] / researchv10dc / 630 / man / src / p_man / man3 / strtol.3l
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

.\"#ident	"@(#)ccsman:g3c/strtol	1.2"
'\"macro stdmacro
.nr X
.if \nX=0 .ds x} STRTOL 3L "630 MTG" "\&"
.TH \*(x}
.SH NAME
strtol, atol, atoi \- convert string to integer
.SH SYNOPSIS
.nf
.B long strtol (str, ptr, base)
.B char \(**str, \(**\(**ptr;
.B int base;
.PP
.B long atol (str)
.B char \(**str;
.PP
.B int atoi (str)
.B char \(**str;
.SH DESCRIPTION
.I strtol\^
returns (as a long integer) the value represented by the character string
pointed to by
.IR str .
The string is scanned up to the first
character inconsistent with the base.
Leading ``white-space'' characters
[as defined by
.I isspace\^
in
.IR ctype (3L)]
are ignored.
.PP
If the value of
.I ptr\^
is not (char \(**\(**)\s-1NULL\s+1,
a pointer to the character terminating the scan is returned in
the location pointed to by
.IR ptr .
If no integer can be formed,
that location
is set to
.IR str ,
and zero is returned.
.PP
If
.I 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
.I base\^
is 16.
.PP
If
.I base\^
is zero, the string itself determines the base thusly: After an
optional leading sign, a leading zero indicates octal conversion,
and a leading ``0x'' or ``0X'' indicates a hexadecimal conversion.  Otherwise,
decimal conversion is used.
.PP
Truncation from long to int can, of course, take place upon
assignment or by an explicit cast.
.PP
.I Atol(str)\^
is equivalent to
.IR "strtol(str, (char \(**\(**)\s-1NULL\s+1, 10)" .
.PP
.I Atoi(str)\^
is equivalent to
.IR "(int) strtol(str, (char \(**\(**)\s-1NULL\s+1, 10)" .
.SH SEE ALSO
atof(3L), ctype(3L).
.SH WARNING
Overflow conditions are ignored.
.Ee

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.