[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
atol()                   Convert String to Long


 include <stdlib.h>

 long       atol(string);                Value of string, converted to long
 char       *string;                     String to be converted

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

                 [whitespace][sign]digits

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


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


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

    The following statements convert a string to a long value and print
    the result.

         #include <stdlib.h>

         long   l;
         char   *s;

         main()
         {
             s = "98765";
             l = atol(s);
             printf("%ld\n",l);
         }

See Also: atoi() atof() ecvt() fcvt() gcvt()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson