Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bcmp(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 bcmp(3C)



        _________________________________________________________________
        bcmp                                                     function
        Compare two areas of memory.
        _________________________________________________________________


        Calling Sequence

        int bcmp(), result, length;
        char *ptr1, *ptr2;
        result = bcmp(ptr1, ptr2, length);



          where   ptr1 is a pointer to the first area.

                  ptr2 is a pointer to the second area.

                  length is the number of bytes to compare.



        Description

        The bcmp function compares two areas of memory, byte by byte, as
        unsigned values.  It compares the number of bytes you specify
        with length; this function comes from the University of
        California Berkeley UNIX (BSD) system.  Unlike the memcmp
        function, the bcmp function tests only for equality.  This
        function does not indicate whether the first area is greater or
        less than the second area.


        Returns

        The bcmp function returns 0 if the areas are equal.  Otherwise,
        it returns a nonzero value.  However, if length is negative, the
        function bcmp returns 0.


        Related Functions

        See also the memcmp function.


        Example

        The following program compares an input string to the username
        mike.
        /* Program test for the bcmp() function */




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





                                                                 bcmp(3C)



        #include <stdio.h>


        int bcmp();
        char buf[80];

        main() {
            printf("Type in a name:  ");
            if (fgets(buf, sizeof(buf), stdin)) {
                if (!bcmp(buf, "mike\n", 5))
                    printf("You typed mike!\n");
                else
                    printf("You did not type mike.\n");
            }
            return 0;
        }






































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



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