Revision as of 22:28, 5 August 2010 editRichfife (talk | contribs)Extended confirmed users7,113 edits You'd have to make a special effort to write a non-thread safe atoi(), but, yes, the reference supports the claim that it's happened at least once.← Previous edit |
Latest revision as of 14:34, 11 June 2017 edit undoTom.Reding (talk | contribs)Autopatrolled, Extended confirmed users, Page movers, Template editors3,871,686 editsm +{{Redirect category shell}} for multiple-{{R}} #Rs using AWB |
(36 intermediate revisions by 16 users not shown) |
Line 1: |
Line 1: |
|
|
#REDIRECT ] |
|
{{lowercase|title=atoi}} |
|
|
The '''atoi''' ('''A'''SCII '''to''' '''i'''nteger) function in the ] is used to convert a string into a numerical representation. |
|
|
|
|
|
|
|
{{Redirect category shell|1= |
|
:<code>int '''atoi'''(const char *str) </code> |
|
|
|
{{R with history}} |
|
|
|
|
|
{{R to section}} |
|
The <code>str</code> 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 ] does not have this deficiency. |
|
|
|
}} |
|
|
|
|
Other problems of atoi are that it is not ] and not ] on some operating systems.<ref name="codecogs_atoi">http://www.codecogs.com/reference/c/stdlib.h/atoi.php</ref> |
|
|
|
|
|
Variants of the '''atoi''' function, '''atol''', '''atof''', and '''atoll''' (the latter formerly known as '''atoq'''), are used to convert a string into a <code>long</code>, <code>double</code>, or <code>long</code> <code>long</code> type, respectively: |
|
|
|
|
|
:<code>long '''atol'''(const char *str)</code> |
|
|
:<code>double '''atof'''(const char *str)</code> |
|
|
:<code>long long '''atoll'''(const char *str)</code> (]) |
|
|
|
|
|
==Standards conformance== |
|
|
|
|
|
The '''atoi''', '''atof''', and '''atol''' functions are a part of the ISO standard C library (]), while the '''atoll''' function is added by ]. |
|
|
|
|
|
However, because of the ambiguity in returning 0 and lack of ]ty and ]ty on some operating system, atoi is considered to be ] by ].<ref name="codecogs_atoi"/> |
|
|
|
|
|
==References== |
|
|
The © 1979 by Bell Telephone Laboratories, Incorporated. |
|
|
|
|
|
The written by ] (November 1971). |
|
|
|
|
|
<references/> |
|
|
|
|
|
|
|
|
==See also== |
|
|
* ] |
|
|
* ] |
|
|
* ] |
|
|
* ] |
|
|
* ] |
|
|
|
|
|
] |
|
|
] |
|
|
|
|
|
] |
|
|
] |
|
|
] |
|