Udostępnij za pośrednictwem


CStringT::Delete

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

int Delete(
   int iIndex,
   int nCount = 1
);

Parameters

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

  • nCount
    The number of characters to be removed.

Return Value

The length of the changed string.

Remarks

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

Example

// 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!

Requirements

Header: cstringt.h

See Also

Reference

CStringT Class

Other Resources

CStringT Members