Export (0) Print
Expand All

CStringT::Mid

Extracts a substring of length nCount characters from this CStringT object, starting at position iFirst (zero-based).

CStringT Mid(
   int iFirst,
   int nCount
) const;
CStringT Mid(
   int iFirst
) const;

iFirst

The zero-based index of the first character in this CStringT object that is to be included in the extracted substring.

nCount

The number of characters to extract from this CStringT object. If this parameter is not supplied, then the remainder of the string is extracted.

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

The function returns a copy of the extracted substring. Mid is similar to the Basic Mid function (except that indexes in Basic are one-based).

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.Mid(2, 3) == _T("cde"));   

Header: cstringt.h

Show:
© 2014 Microsoft