Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>atoi() convert string to integer</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
atoi()                   Convert String to Integer

 #include <stdlib.h>

 int        atoi(string);                The integer value of string
 char       *string;                     String to be converted

    atoi() converts 'string' to an integer value.  atoi() does not
    recognize decimal points or exponents.  'string' has the following
    format:

                [whitespace][sign]digits
     where
            whitespace       any number of tab or space characters;
            sign             + or -
            digits           one or more decimal digits.

    Returns:    The integer value of 'string'.  If 'string' cannot be
                converted to an integer, 0 is returned.  The return value
                is undefined for overflow.

  -------------------------------- Example ---------------------------------

    The following statements convert a string to an integer and print the
    result.

         #include <stdio.h>

         char   *s;
         int    i;

         main()
         {
             s = "12345";
             i = atoi(s);
             printf("%d\n",i);
         }

See Also: atof() atol() ecvt() fcvt() gcvt()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson