Deletes a character or characters from a string starting with the character at the given index.

int Delete(
   int iIndex,
   int nCount = 1


The zero-based index of the first character in the CStringT object to delete.


The number of characters to be removed.

The length of the changed string.

If nCount is longer than the string, the rest of the string will be removed.

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

CAtlString str(_T("Soccer is best, but hockey is quicker!"));
_tprintf_s(_T("Before: %s\n"), (LPCTSTR)str);

int n = str.Delete(6, 3);
_tprintf_s(_T("After: %s\n"), (LPCTSTR)str);
ASSERT(n == str.GetLength());
Before: Soccer is best, but hockey is quicker!
After: Soccer best, but hockey is quicker!

Header: cstringt.h