strnicmp

Compares, with case insensitivity, a specified number of characters in one string to another string

Local Servers:nonblocking
Remote Servers:N/A
Classification:Other
Service:String Manipulation

Syntax

  #include <string.h>  
   
  int strnicmp  (  
     const char   *s1,   
     const char   *s2,   
     size_t        len);
  

Parameters

s1
(IN) Points to the string to be compared to the string pointed to by s2.
s2
(IN) Points to the string to be compared to the string pointed to by s1.
len
(IN) Specifies the number of characters to compare.

Return Values

The strnicmp function returns an integer less than, equal to, or greater than 0, indicating that the string pointed to by s1 is less than, equal to, or greater than the string pointed to by s2.

Remarks

The strnicmp function compares, with case insensitivity, the string pointed to by s1 to the string pointed to by s2, for at most len characters.

See Also

strcmp, stricmp, strncmp

Example

  #include <string.h>  
  #include <stdio.h>  
   
  main ()  
  {  
     printf ("%d\n", strnicmp ("abcdef", "ABCXXX", 10) );  
     printf ("%d\n", strnicmp ("abcdef", "ABCXXX",  6) );  
     printf ("%d\n", strnicmp ("abcdef", "ABCXXX",  3) );  
     printf ("%d\n", strnicmp ("abcdef", "ABCXXX",  0) );  
  }
  

produces the following:

  -20  
  -20  
  0  
  0