Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signcmp(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                              signcmp(3C)



        _________________________________________________________________
        signcmp                                                  function
        Compare successive character values in two strings.
        _________________________________________________________________


        Calling Sequence

        char *firstring, *secstring;
        int result;
        result = signcmp(firstring, secstring);



          where   firstring and secstring are pointers to strings to
                  compare.
                  result gets the following value:

                  -1     if firstring < secstring
                  0      if firstring == secstring
                  +1     if firstring > secstring



        Description

        Use the signcmp function to compare the successive character
        values of two strings.  It compares the characters as signed
        values.  The scan ends when signcmp encounters unequal
        characters, or when both strings are exhausted (that is, it
        reaches the character \000).  Unlike the signncmp function,
        signcmp doesn't require you to specify a maximum number of
        characters to scan.


        Returns

        The signcmp function returns the result as described above.


        Related Functions

        See also the memcmp, signncmp, strcmp, and strncmp functions.


        Example

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

        #include <stdio.h>




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





                                                              signcmp(3C)



        int     result;
        char    first[80], second[80];

        main() {
            printf("Enter first string:\n");
            scanf("%s", &first);
            printf("Enter second string:\n");
            scanf("%s", &second);
            result = signcmp(first, second);
            switch (result) {
                case -1:   printf("First, '%s,' is earlier.\n",
                                  first);
                           break;
                case 0:    printf("Strings are equal.\n");
                           break;
                case 1:    printf("Second, '%s,' is earlier.\n",
                                  second);
            }
        }

        Successive calls to the program test with the entries

        jack
        Jack

        Jack
        Jill

        Jill.1
        Jill.2

        generate the following output strings:

        Second, 'Jack,' is earlier.

        First, 'Jack,' is earlier.

        First, 'Jill.1,' is earlier.
















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



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