strcasecmp()


Case-insensitive comparison of strings.

Syntax

strcasesmp(string1, string2, [n])

Parameter

Parameter

Definition

string1

first string to be compared

string2

second string to be compared

n

length of prefix to consider for comparison

Description

The strcasecmp() function is equivalent to the C language strcasecmp() when called with 2 arguments and strncasencmp() when called with 3 arguments. It is used to do a case insensitive comparison of two strings, or the prefix of two strings. 

This function will return 0 if both strings differ only by case (or the prefix of both strings differ only by case when the optional third argument is used). Otherwise, non-zero is returned. 

This function does not set the PSL errno variable.

Example

The following is an example of the strcasecmp() function:

str1="TEST"; str2="test";
if(strcasecmp(str1, str2)==0)
{
print ("The strings are the same, or differ only by case.\n");
}
else
{
print ("The strings are different.\n");
}