01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

STRTOL ( 3C ) STRTOL ( 3C )<br />

NAME<br />

strtol, atol, atoi - convert string to integer<br />

SYNOPSIS<br />

long strtol (str, ptr, base)<br />

char *str;<br />

char **ptr;<br />

int base;<br />

long atol (str)<br />

char •str;<br />

int atoi (str)<br />

char *str;<br />

DESCRIPTION<br />

Strtol returns as a long integer the value represented by the character<br />

string str. The string is scanned up to the first character<br />

inconsistent with the base. Leading "white-space" characters are<br />

ignored.<br />

If the value of ptr is not (char **)NULL, a pointer to the character<br />

terminating the scan is returned in *ptr. If no integer can be<br />

formed, * ptr is set to str, and zero is returned.<br />

If base is positive (and not greater than 36), it is used as the base<br />

for conversion. After an optional leading sign, leading zeros are<br />

ignored, and "Ox" or "OX" is ignored if base is 16.<br />

If base is zero, the string itself determines the base thus: After an<br />

optional leading sign, a leading zero indicates octal conversion,<br />

and a leading "Ox" or "OX" hexadecimal conversion. Otherwise,<br />

decimal conversion is used.<br />

Truncation from long to int can, of course, take place upon assignment,<br />

or by an explicit cast.<br />

Atol(str} is equivalent to strtol(str, {char **}NULL, 10}.<br />

Atoi(str) is equivalent to {int) strtol(str, (c har **}NULL, 10 ).<br />

SEE ALSO<br />

scanf(3S), strtod(3C) .<br />

BUGS<br />

Overflow conditions are ignored.<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!