CString::Left

This method extracts the first (leftmost) nCount characters from this CString object and obtains a copy of the extracted substring. If nCount exceeds the string length, then the entire string is extracted. Left is similar to the Basic LEFT$ function, except that indexes are zero-based.

CString Left(
int nCount )
const; 

Parameters

  • nCount
    Specifies the number of characters to extract from this CString object.

Return Value

A CString object containing a copy of the specified range of characters. Note that the returned CString object may be empty.

Example

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

// example for CString::Left
CString s( _T("abcdef") );
ASSERT( s.Left(2) == _T("ab") );

Requirements

  Windows CE versions: 1.0 and later
  Header file: Declared in Afx.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also

CString::Mid, CString::Right