Misplaced Pages

atoi

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

This is an old revision of this page, as edited by 116.74.105.130 (talk) at 07:47, 29 May 2009 (Standards conformance). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Revision as of 07:47, 29 May 2009 by 116.74.105.130 (talk) (Standards conformance)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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 convert a string into a long, float, 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.


Atoi is character to string converter

See also

Categories: