Format
#include <string.h> int strcmpi(const char *string1, const char *string2);
Language Level: Extension
strcmpi compares string1 and string2
without sensitivity to case. All alphabetic characters in the two
arguments string1 and string2 are converted
to lowercase before the comparison.
The function operates on null-ended strings. The string arguments to the function are expected to contain a null character (\0).
Return Value
strcmpi returns a value indicating the
relationship between the two strings, as follows:
| Value | Meaning |
| Less than 0 | string1 less than string2 |
| 0 | string1 equivalent to string2 |
| Greater than 0 | string1 greater than string2. |
If n is greater than the length of string1 or string2, characters that follow a null character are not compared.
Example
This example uses strcmpi to compare two
strings.
#include <stdio.h> #include <string.h>
int main(void)
{
/* Compare two strings without regard to case */
if (0 == strcmpi("hello", "HELLO"))
printf("The strings are equivalent.\n");
else
printf("The strings are not equivalent.\n");
return 0;
/**********************************************
The output should be:
The strings are equivalent. **********************************************/ }
![]()
strcspn -- Compare Strings
for Substrings
strdup --
Duplicate String
stricmp --
Compare Strings as Lowercase
strncmp --
Compare Strings
strnicmp --
Compare Strings Without Case Sensitivity
wcscmp --
Compare Wide-Character Strings
wcsncmp --
Compare Wide-Character Strings
<string.h>