CString::Compare

int Compare( LPCTSTR lpsz ) const;

Return Value

Zero if the strings are identical, < 0 if this CString object is less than lpsz, or > 0 if this CString object is greater than lpsz.

Parameters

lpsz

The other string used for comparison.

Remarks

Compares this CString object with another string using the generic-text function _tcscmp. The generic-text function _tcscmp, which is defined in TCHAR.H, maps to either strcmp, wcscmp, or _mbscmp depending on the character set that is defined at compile time. Each of these functions performs a case-sensitive comparison of the strings, and is not affected by locale. For more information, see strcmp, wcscmp, _mbscmp in the Run-Time Library Reference.

Example

The following example demonstrates the use of CString::Compare.

// example for CString::Compare
CString s1( "abc" );
CString s2( "abd" );
ASSERT( s1.Compare( s2 ) == -1 ); // Compare with another CString.
ASSERT( s1.Compare( "abe" ) == -1 ); // Compare with LPTSTR string.

CString OverviewClass MembersHierarchy Chart

See Also   CString::CompareNoCase, CString::Collate, CString::CollateNoCase