基本介紹
- 中文名:CString::Mid
- 外文名:CString::Mid
說明,參數,
說明
CString Mid( int nFirst ) const;
throw( CMemoryException );
CString Mid( int nFirst, int nCount ) const;
throw( CMemoryException );
返回值:
參數
nFirst 此CString對象中的要被提取的子串的第一個字元的從零開始的索引。
nCount 要從此CString對象中提取的字元數。如果沒有提供這個參數,則字元串的其餘部分都被提取。
示例:下面的例子說明了如果如何使用CString::Mid。
// CString::Mid示例:
CString s( _T("abcdef") );
ASSERT( s.Mid( 2, 3 ) == _T("cde") );
以下為MSDN說明:
CString::Mid
This method extracts a substring of length nCount characters from this CString object, starting at position nFirst (zero-based). The method returns a copy of the extracted substring. Mid is similar to the Basic MID$ function, except that indexes are zero-based.
CString Mid(
int nFirst,
int nCount )
CString Mid(
int nFirst)
const;
Parameters
nFirst
Specifies the zero-based index of the first character in this CString object that is to be included in the extracted substring.
nCount
Specifies the number of characters to extract from this CString object. If this parameter is not supplied, the remainder of the string is extracted.
Return Value A CString object that contains 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::Mid.
// example for CString::Mid
CString s( _T("abcdef") );
ASSERT( s.Mid( 2, 3 ) == _T("cde") );