In C, strcasecmp() compares two C-strings and ignores letter case. strcasecmp("Hi", "hi") is 0. It is common on POSIX systems and is not part of ISO C string.h.
You pass two C-strings. Both are required. The result uses the same 0 / less than 0 / greater than 0 idea as strcmp(). Include <strings.h> where it is available.
Syntax
Pass both strings. Start with this call.
C
strcasecmp("Hi", "hi");
Call
What it does
strcasecmp("Hi", "hi")
Returns 0 because the letters match when case is ignored.
This is a POSIX function. On Windows, people often use _stricmp() instead.
Library declarations
C
int strcasecmp(const char *s1, const char *s2);
Parameters
Parameter
Description
s1
Required. The first C-string.
s2
Required. The second C-string.
Return Value
Return Value
Description
0
The strings match when letter case is ignored.
Less than 0
The first string comes first.
Greater than 0
The first string comes after.
C Examples
Example 1 — Check Equality Ignoring Case
Test whether two strings match when letter case is ignored. Prefer this over folding both strings by hand with tolower.