(ANSI Standard)
#include <stdlib.h> i = atoi(s);
"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.
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.
Copyright © 1996, Thinkage Ltd.