Misplaced Pages

Atoi: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 02:31, 27 February 2009 editLofty abyss (talk | contribs)Oversighters, Administrators46,499 editsm Reverted edits by 119.152.5.127 to last revision by SmackBot (HG)← Previous edit Revision as of 02:32, 27 February 2009 edit undo119.152.5.127 (talk) Standards conformanceNext edit →
Line 7: Line 7:
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. 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.


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>float</code>, or <code>long</code> <code>long</code> type, respectively: Variants of the '''atoi''' function, '''atol''', '''atof''', and '''atoll''' (the latter formerly known as '''atoq'''), are used to

:<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 ].

==See also==
* ]
* ]
* ] * ]
* ] * ]

Revision as of 02:32, 27 February 2009

This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Atoi" – news · newspapers · books · scholar · JSTOR (January 2009) (Learn how and when to remove this message)

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

Categories:
Atoi: Difference between revisions Add topic