Atoi

Atoi

The atoi (ASCII to Integer) function in the C programming language is used to convert a string into a numerical representation.

int atoi (const char *string)

Where string is the string, represented by an array of characters. When atoi encounters a string with no numerical sequence, it returns a 0 (zero). Also, if the string holds a valid sequence of digits that represents the number 0, it would also return a 0, making it impossible to tell from the return value alone whether the string held a valid number or not. The newer function strtol does not have this deficiency.

Variants of the atoi function, atol, atof, and atoll (the latter formerly known as atoq), are used to convert a string into a long, float, or long long integer, respectively:

long atol (const char *string)
double atof(const char *string)
long long atoll (const char *string) (C99)

Standards conformance

The atoi, atof, and atol functions are a part of the ISO standard C library (C89), while the atoll function is added by C99.

See also

Search another word or see Atoion Dictionary | Thesaurus |Spanish
Copyright © 2014 Dictionary.com, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature