aattooii() -- General Function (libc)

Convert ASCII strings to integers
#iinncclluuddee <ssttddlliibb.hh>
iinntt aattooii(_s_t_r_i_n_g) cchhaarr *_s_t_r_i_n_g;

aattooii()  converts  _s_t_r_i_n_g  into the  binary  representation  of an  integer.
_s_t_r_i_n_g may contain a leading sign and any number of decimal digits.  aattooii()
ignores leading  blanks and tabs; it stops scanning  when it encounters any
non-numeral other than the leading sign, and returns the resulting iinntt.

_E_x_a_m_p_l_e
The following demonstrates aattooii(). It takes a string typed at the terminal,
turns it into an integer, then prints that integer on the screen.  To exit,
type <ccttrrll-CC>.

#include <stdlib.h>

main()
{
    extern char *gets();
    extern int atoi();
    char string[64];

    for(;;) {
        printf("Enter numeric string: ");
        if(gets(string))
            printf("%d\n", atoi(string));
        else
            break;
    }
}

_S_e_e _A_l_s_o
lliibbcc
ANSI Standard, section 7.10.1.2
POSIX Standard, section 8.1

_N_o_t_e_s
aattooii does not check to see if the number represented by _s_t_r_i_n_g fits into an
iinntt.  It returns zero if you hand it a string that it cannot interpret.
