Syntax
#include <string.h> int strnicmp(const char *string1, const char *string2, int n);Description
strnicmp compares, at most, the first n characters of string1 and string2. It operates on null-terminated strings.
strnicmp is case-insensitive; the uppercase and lowercase forms of a letter are considered equivalent. Conversion to lowercase uses locale information.
strnicmp returns a value indicating the relationship between the substrings, as listed below: compact break=fit.
Value
This example uses strnicmp to compare two strings.
#include <string.h>#include <stdio.h>
int main(void)
{
   char *str1 = "THIS IS THE FIRST STRING";
   char *str2 = "This is the second string";
   int numresult;
     /* Compare the first 11 characters of str1 and str2
        without regard to case                                                */
   numresult = strnicmp(str1, str2, 11);
   if (numresult < 0)
      printf("String 1 is less than string2.\n");
   else
      if (numresult > 0)
         printf("String 1 is greater than string2.\n");
      else
         printf("The two strings are equivalent.\n");
   return 0;
   /****************************************************************************
      The output should be:
      The two strings are equivalent.
   ****************************************************************************/
}
Related Information