Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>strcoll() compare two strings according to locale</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strcoll()               Compare Two Strings According to Locale

 #include   <string.h>                   Required for declarations only

 int        strcoll(string1,string2);
 const char *string1;                    First string
 const char *string2;                    Second string

    strcoll() compares 'string1' and 'string2' lexicographically ('a' is
    less than 'b', 'b' is equal to 'b', 'c' is greater than 'b', and 'A'
    is less than 'a'), according to the collating sequence set by
    setlocale().

       Returns:     A value indicating the relationship between the two
                    strings:

                          Comparison          Returned

                    'string1' <  'string2'      < 0
                    'string1' == 'string2'        0
                    'string1' >  'string2'      > 0

         Notes:     strcmp() expects to operate on null-terminated
                    strings.  No overflow checking is done when strings
                    are copied or appended.

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

    This example finds the string that sorts first (alphabetically)
    according to the locale and prints the strings accordingly:

           #include <string.h>
           #include <stdio.h>               /* for printf */

           char str1[20], str2[20];
           int order;

           main()
           {
               strcpy(str1,"alligator");
               strcpy(str2,"albatross");
               if ((order = strcoll(str1,str2)) <= 0)
                   printf("1. %s     2. %s  \n", str1,str2);
               else
                   printf("1.  %s     2. %s  \n",str2,str1);
           }


See Also: strcmp() strcmpi() stricmp() strncmp()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson