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>strcmpi() compare two strings, case insensitive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strcmpi()               Compare Two Strings, Case Insensitive

 #include   <string.h>                   Required for declarations only

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


        This is the case insensitive version of strcmp(). strcmpi()
        compares 'string1' and 'string2' lexicographically, without
        regard to case ('a' or 'A' is less than 'b' or 'B', 'b' or 'B' is
        equal to 'b' or 'B', 'c' or 'C' is greater than 'b' or 'B').
        strcmpi() is the same as stricmp(), except that it is implemented
        as a macro.

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

                          Comparison          Returned

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

         Notes:     strcmpi() 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)
    without regard to case 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 = strcmpi(str1,str2)) <= 0)
                   printf("1. %s     2. %s  \n", str1,str2);
               else
                   printf("1.  %s     2. %s  \n",str2,str1);
           }

See Also: stricmp() strnicmp() strncmpi()

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