stricmp
| String Manipulation Functions |
Performs a case-insensitive comparison of two strings.
int stricmp( const char *string1, const char *string2);
| string1 | The first string for comparison. |
| string2 | The second string for comparison. |
Return Values
Returns a value indicating the lexicographical relation between the strings:
| Return value | Description |
| <0 | string1 is less than string2 |
| 0 | string1 is the same as string2 |
| >0 | string1 is greater than string2 |
Example
The following example compares two strings, string1 and string2, which are identical except for the word "quick" which is lowercase in string1 and uppercase in string2. strcmp, which is case-sensitive, returns an unequal comparison. stricmp, which ignores case, returns an equal one.
#include <string.h>
int result; char tmp[20]; char string1[] = "The quick brown dog jumps over the lazy fox"; char string2[] = "The QUICK brown dog jumps over the lazy fox";
// Case-sensitive comparison
result = strcmp(string1, string2);
if (result > 0) strcpy(tmp, "greater than"); else if (result < 0) strcpy(tmp, "less than"); else strcpy(tmp, "equal to");
lr_output_message ("strcmp: String 1 is %s string 2", tmp);// Case-insensitive comparison
result = stricmp(string1, string2);
if (result > 0) strcpy(tmp, "greater than"); else if (result < 0) strcpy(tmp, "less than"); else strcpy(tmp, "equal to");
lr_output_message ("stricmp: String 1 is %s string 2", tmp);Example: Output:
Action.c(17): strcmp: String 1 is greater than string 2
Action.c(28): stricmp: String 1 is equal to string 2

