Stricmp( ) Function

Stricmp( ) Function :

This function compares the two strings.The character of the strings may be in lower case or upper case the function doesn't discriminates between them,i.e. This function compares two strings without case. If the strings are same it returns to zero otherwise non-zero value.

Program :
#include<stdio.h>
main( )
{
 char sr[10],tar[10];
int diff;
printf("Enter string(1) :");
gets(sr);
printf("Enter string(2):");
gets(tar);
diff=stricmp(sr,tar);
if(diff==0)
puts("The two strings are identical.");
else
puts('The two strings are different ");
getche( );
}

OUTPUT
Enter string(1) :HELLO
Enter string(2) :hello
The two strings are identical.

Explanation :
In the above program two strings are entered.Both the strings are compared using stricmp( ) function.If both the strings are identical it returns zero other wise non-zero value.the returned value of the stricmp( ) function is assigned to variable 'diff '. The if condition checks the value of the variable 'diff ' and the respective message is displayed.