Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

StrCmpC function

Compares strings using C run-time (ASCII) collation rules. The comparison is case-sensitive.


int StrCmpC(
  _Out_ LPCTSTR lpStr1,
  _Out_ LPCTSTR lpStr2


lpStr1 [out]


A pointer to the first null-terminated string to be compared.

lpStr2 [out]


A pointer to the second null-terminated string to be compared.

Return value

Type: int

Returns zero if the strings are identical. Returns a positive value if the string pointed to by lpStr1 is alphabetically greater than that pointed to by lpStr2. Returns a negative value if the string pointed to by lpStr1 is alphabetically less than that pointed to by lpStr2.


It is strongly recommended that you use the CompareString function in place of this function. StrCmpC was designed for comparing canonical strings. These strings are not localized and consist only of characters below ASCII value 128. Therefore, it will not function correctly with a double-byte character set (DBCS) or other multiple-character data.

This function locates the first unequal characters and returns a positive number if the character from the first string is greater than the character from the second, a negative number if it is less, or zero if they are equal. For example, if lpStr1="abczb" and lpStr2="abcdefg", StrCmpC determines that the first unequal character is at position four ("z" in lpStr1 and "d" in lpStr2) and returns a positive value since the ASCII code for "z" is greater than the ASCII code for "d".

For those versions of Windows that do not include StrCmpC in Shlwapi.h, this function's individual ANSI or Unicode version must be called directly from Shlwapi.dll. StrCmpCA is ordinal 155 and StrCmpCW is ordinal 156.


Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]






Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

StrCmpCW (Unicode) and StrCmpCA (ANSI)

See also




Community Additions

© 2015 Microsoft