ATOI - convert ASCII string to integer.

(ANSI Standard)

Usage:

#include <stdlib.h>
i = atoi(s);

Where:

const char *s;
points to a string of ASCII characters which correspond to a valid integer, e.g. "-325".
int i;
is the integer corresponding to the given ASCII string.

Description:

"atoi" converts the string pointed to by "s" into an integer. The string may consist of any number of blanks and/or tabs, possibly followed by a sign, followed by a string of digits. Conversion stops when the first non-digit is encountered.

Notes:

Previous versions of "atoi" treated a number as octal if it had a leading zero and decimal otherwise. The ANSI standard requires that "atoi" behave like

(int) strtol(s,NULL,10)

which means that numbers are always treated as decimal. The current version of "atoi" follows the ANSI standard.

See Also:

expl c lib strtol

expl c lib scanf

Copyright © 1996, Thinkage Ltd.