Revision as of 18:34, 5 May 2010 edit130.166.209.8 (talk) →Standards conformance← Previous edit | Revision as of 02:47, 26 May 2010 edit undoFydfyd (talk | contribs)100 edits added authoritative reference, removed Unreferenced tagNext edit → | ||
Line 1: | Line 1: | ||
{{Unreferenced|date=January 2009}} | |||
{{lowercase|title=atoi}} | {{lowercase|title=atoi}} | ||
The '''atoi''' ('''A'''SCII '''to''' '''i'''nteger) function in the ] is used to convert a string into a numerical representation. | The '''atoi''' ('''A'''SCII '''to''' '''i'''nteger) function in the ] is used to convert a string into a numerical representation. | ||
Line 16: | Line 15: | ||
The '''atoi''', '''atof''', and '''atol''' functions are a part of the ISO standard C library (]), while the '''atoll''' function is added by ]. | The '''atoi''', '''atof''', and '''atol''' functions are a part of the ISO standard C library (]), while the '''atoll''' function is added by ]. | ||
==References== | |||
© 1979 by Bell Telephone Laboratories, Incorporated | |||
==See also== | ==See also== |
Revision as of 02:47, 26 May 2010
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 *str)
The str
argument is a string, represented by an array of characters, containing the characters of a signed integer number. The string must be null-terminated. When atoi encounters a string with no numerical sequence, it returns zero (0). If the string holds a valid sequence of digits that represents the number 0, it also returns a 0, making it impossible to tell from the return value alone whether the string holds 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
, double
, or long
long
type, respectively:
long atol(const char *str)
double atof(const char *str)
long long atoll(const char *str)
(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.
References
The Version 7 Unix Manual Pages © 1979 by Bell Telephone Laboratories, Incorporated