Поделиться через


CStringT::Left

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

CStringT Left(
   int nCount
) const;

Параметры

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

Возвращаемое значение

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

Заметки

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

For multibyte character sets (MBCS), nCount refers to each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.

Пример

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

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

Требования

Header: cstringt.h

См. также

Основные понятия

CStringT Class

CStringT Members