I think the problem is likely a UNICODE issue. With UNICODE enabled in your project, CStrings default to "wide" character strings. A "wide" character is 2 bytes whereas normal char is 1 byte. You can use the "wide" versions of the comparison functions, wcscmp() v. strcmp(), or to keep everything portable, use the TCHAR macros. _tcscmp() is a macro that will evaluate to strcmp() in MCBS builds or wcscmp() in UNICODE builds.