Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

atol(3)

atof(3)

isspace(3)

ctype(3)

scanf(3)

strtod(3)

strtol(3)

strtoul(3)



  atoi(3)                             CLIX                             atoi(3)



  NAME

    atoi - Converts a string to an integer

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    long atoi(
      char *str );

  PARAMETERS

    str   Specifies a pointer to a character string.

  DESCRIPTION

    The atoi() function returns as a base 10 integer the value represented by
    the character string pointed to by str.  The string is scanned up to the
    first character inconsistent with the base.  Leading white space
    characters (as defined in isspace(3)) are ignored.

    Except for its behavior in the event of an error, the atoi(str) function
    is equivalent to (int)strtol(str, (char **)NULL, 10).

  EXAMPLES

    The following uses atoi() to convert a string into a long:

    main(argc,argv)
    int  argc;
    char **argv;
    {
         int number;               /*Type is int.*/
         char string[100];          /*Give input string enough space!"*/
         printf("Enter a string: ");    /*Prompt*/
         scanf("%s",string);        /*Get user input, say "589317.476adico"...*/
         number=atoi(string);       /*Convert user input into integer (589317)*/
         printf("The number is %i.0\n", number);   /*Print it to stdout.*/
    }


  RETURN VALUES

    If a correct value causes overflow, LONG_MAX or LONG_MIN (as defined in
    <limits.h>) is returned (according to the sign of the value), and errno is
    set to ERANGE.

    Otherwise, the integer representation of str is returned.



  2/94 - Intergraph Corporation                                              1






  atoi(3)                             CLIX                             atoi(3)



  ERRORS

    [ERANGE]   No conversion was possible, or the conversion results in an
               overflow.

  RELATED INFORMATION

    Functions:  atol(3), atof(3), isspace(3), ctype(3), scanf(3), strtod(3),
    strtol(3), strtoul(3)













































  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026