| atoi | Function (tigcc.a)

stdlib.h

short atoi (const char *str);

Converts a string to a short integer.

atoi converts the string pointed to by str to integer. atoi recognizes (in the following order):

- an optional string of spaces [ws];
- an optional sign ('+', '-', or special "small" minus used in TI-Basic) [sn];
- a string of digits [ddd].

The characters must match this generic format:
[ws] [sn] [ddd]
In atoi, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are wrong in a case of overflow). atoi returns the converted value of the input string. If the string cannot be converted, the return value is 0. See strtol and strtoul for conversions which allow much greater flexibility.