Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ atou(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 atou(3C)



        _________________________________________________________________
        atou                                                     function
        Convert an ASCII character string to an unsignedinteger.
        _________________________________________________________________


        Calling Sequence

        unsigned num, atou();
        char *string;
        num = atou(string);



          where   num is an unsigned integer to receive the result.

                  string is a byte pointer to a character array
                  containing optional space characters followed by
                  digits.



        Description

        Use the atou function to convert an ASCII string to an unsigned
        integer.  It ignores leading whitespace characters (blanks and
        tabs).  The first nondigit terminates the string.

        The include file dg_stdio.h defines this function.


        Returns

        The atou function returns the unsigned integer value.  It does
        not return an error message if the number is too large; instead,
        it returns the largest unsigned integer, 4,294,967,295.  If the
        string is not numeric, the function atou returns 0.


        Related Functions

        See also the utoa, atof, atoi, atol, and sscanf functions.


        Example

        /* Program test for the atou() function */

        #include <stdio.h>
        #include <math.h>




        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                 atou(3C)



        unsigned result, atou();
        unsigned i = 1;

        main(argc, argv)
        int     argc;
        char    *argv[];
        {
            while (i < argc) {
                printf("The result from %s is %u.\n", argv[i],
                       result = atou(argv[i]));
                i++;
            }
        }

        If you call the program test with the input numbers

        10
        -10
        +10.5
        -10.5
        32,255

        you generate the result

        The result from 10 is 10.
        The result from -10 is 4294967286.
        The result from +10.5 is 10.
        The result from -10.5 is 4294967286.
        The result from 32 is 32.
        The result from 255 is 255.
























        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



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