Clever Geek Handbook
📜 ⬆️ ⬇️

atoi (si)

The atoi function ( A SCII to i nteger, from ASCII to an integer) in the C programming language is used to convert (convert) a string to a numeric form.

int atoi (const char *str)

The str argument means a string represented as an array of characters containing characters of a signed integer ( int type) of a number. The string must be null terminated, that is, end with the character "\ 0". When atoi() receives a string without number sequences, then it returns zero (0). The line should begin either directly with a numerical sequence, or with any combination of whitespace characters. After processing a numerical sequence, any non-numerical remainder of the string (if any) is ignored. If the string contains the correct sequence of digits representing the number 0, then 0 is also returned, and it is not possible to determine from the returned number whether the string contains the correct number or not. The newer strtol function does not have a similar drawback, so when it is critical, you should use it. In contrast, atoi, when processing values ​​from dialog boxes, allows you to set fields like “enter the number of retries on reading error” and fill them by default with a non-numeric, and more intuitive text value like “skip errors without retrying”, which will be interpreted as "0 repeats "without unnecessary actions of the programmer.

Variants of the atoi function - atol , atof, and atoll (later known as atoq ) are used to cast a string to long , double or long long types, respectively:

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

Compliance

The atoi , atof, and atol functions are part of the C89 C (ISO) standard library, and the atoll function has been added to the C99 standard .

See also

  • atof
  • itoa
  • strtod
  • strtol

Links

  • Description of atoi from C ++ Reference
  • atof, atoi, atol - convert to floating - usage example (Russian)
  • Atoi function - description and example of use (rus.)
  • atoi in man'ah (rus.)
Source - https://ru.wikipedia.org/w/index.php?title=Atoi_(Си)&oldid=99493326


More articles:

  • Brendel, Joachim
  • NGC 1136
  • Przyrovsky, Sebastian
  • NGC 1146
  • Chandra vulgaris
  • Zhitnaya Polyana
  • Pomors
  • NGC 1183
  • NGC 1193
  • Landslides in Vargas State

All articles

Clever Geek | 2019