strcmpi( ) function in C is same as strcmp() function. But, strcmpi( ) function is not case sensitive. i.e, “A” and “a” are treated as same characters. Where as, strcmp() function treats “A” and “a” as different characters.
Both functions compare two given strings and returns zero if they are same.
If length of string1 < string2, it returns < 0 value. If length of string1 > string2, it returns > 0 value. Syntax for strcmp( ) function is given below.
int strcmpi ( const char * str1, const char * str2 );
example:
strcmpi("ABC","abc");
[Here,
first comparison: A==a
second comparison: B==b
Thired comparison: C==c
So result = 0]
illustrate strcmpi() C program:
#include<stdio.h>
int main()
{
int r;
char str1[40],str2[40];
printf("Enter first string : ");
gets(str1);
printf("Enter second string : ");
gets(str2);
r = strcmpi(str1,str2);
printf("Result : %d",r);
getch();
return 0;
}