### strnicmp -- Compare Strings Without Case Sensitivity

Format

>     #include <string.h>
>     int strnicmp(const char *string1, const char *string2, int n);

Language Level: Extension
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.

Return Value
strnicmp returns a value indicating the relationship between the substrings, as listed below:

Value | Meaning
Less than 0 | substring1 less than substring2
0 | substring1 equivalent to substring2
Greater than 0 | substring1 greater than substring2.

Example
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.
       *********************************************************/
    }

strcmp -- Compare Strings
strcmpi -- Compare Strings Without Case Sensitivity
stricmp -- Compare Strings as Lowercase
strncmp -- Compare Strings
wcscmp -- Compare Wide-Character Strings
wcsncmp -- Compare Wide-Character Strings
<string.h>