Compartilhar via


CStringT::Left

Extracts the leftmost nCount characters from this CStringT object and returns a copy of the extracted substring.

CStringT Left(
   int nCount
) const;

Parameters

  • nCount
    The number of characters to extract from this CStringT object.

Return Value

A CStringT object that contains a copy of the specified range of characters. The returned CStringT object may be empty.

Remarks

If nCount exceeds the string length, then the entire string is extracted. Left is similar to the Basic Left function.

For multi-byte character sets (MBCS), nCount treats each 8-bit sequence as a character, so that nCount returns the number of multi-byte characters multiplied by two.

Example

// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;

CAtlString s(_T("abcdef"));
ASSERT(s.Left(2) == _T("ab"));   

Requirements

Header: cstringt.h

See Also

Reference

CStringT Class