Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signncmp(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                             signncmp(3C)



        _________________________________________________________________
        signncmp                                                 function
        Compare successive character values of two strings.
        _________________________________________________________________


        Calling Sequence

        char *firstring, *secstring;
        int max, result;
        result = signncmp(firstring, secstring, max);


          where   firstring and secstring are pointers to strings to
                  compare.
                  max specifies the maximum number of characters to
                  scan.
                  result gets the following value:

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



        Description

        Use the signncmp function to compare successive character values
        of two strings, when you want to specify a maximum number of
        characters to scan.  The scan ends when one of the following
        occurs:

        *    signncmp encounters unequal characters.

        *    Both strings are exhausted (that is, signncmp reaches the
             character \000).

        *    max characters have been scanned.  The comparison is made on
             characters as signed values.


        Returns

        The signncmp function returns the result, as described above.


        Related Functions

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





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





                                                             signncmp(3C)



        Example

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

        #include <stdio.h>
        #define MAX     80

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

        main() {
            printf("Enter first string:\n");
            scanf("%s", &first);
            printf("Enter second string:\n");
            scanf("%s", &second);
            result = signncmp(first, second, MAX);
            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

        alpha
        GAMMA

        alpha
        gamma

        gamma
        gamma

        generate the outputs

        Second, 'GAMMA,' is earlier.

        First, 'alpha,' is earlier.

        Strings are equal.









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



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