Export (0) Print
Expand All


Visual Studio 6.0


TCHAR GetAt( int nIndex ) const;

Return Value

A TCHAR containing the character at the specified position in the string.



Zero-based index of the character in the CString object. The nIndex parameter must be greater than or equal to 0 and less than the value returned by GetLength. The Debug version of the Microsoft Foundation Class Library validates the bounds of nIndex; the Release version does not.


You can think of a CString object as an array of characters. The GetAt member function returns a single character specified by an index number. The overloaded subscript ([]) operator is a convenient alias for GetAt.


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

// example for CString::GetAt
CString s( "abcdef" );
ASSERT( s.GetAt(2) == 'c' );

CString OverviewClass MembersHierarchy Chart

See Also   CString::GetAt, CString::GetLength, CString::operator []

© 2014 Microsoft