CStringT::Insert
Inserts a single character or a substring at the given index within the string.
int Insert(
int iIndex,
PCXSTR psz
);
int Insert(
int iIndex,
XCHAR ch
);
Параметры
iIndex
The index of the character before which the insertion will take place.psz
A pointer to the substring to be inserted.ch
The character to be inserted.
Возвращаемое значение
The length of the changed string.
Заметки
The iIndex parameter identifies the first character that will be moved to make room for the character or substring. If nIndex is zero, the insertion will occur before the entire string. If nIndex is higher than the length of the string, the function will concatenate the present string and the new material provided by either ch or psz.
Пример
// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;
CAtlString str(_T("SoccerBest"));
int n = str.Insert(6, _T("is "));
ASSERT(n == str.GetLength());
_tprintf_s(_T("1: %s\n"), (LPCTSTR) str);
n = str.Insert(6, _T(' '));
ASSERT(n == str.GetLength());
_tprintf_s(_T("2: %s\n"), (LPCTSTR) str);
n = str.Insert(55, _T('!'));
ASSERT(n == str.GetLength());
_tprintf_s(_T("3: %s\n"), (LPCTSTR) str);
Требования
Header: cstringt.h