CString::TrimRight
This method trims trailing white-space characters from the string. It also removes trailing new line, space, and tab characters from the string.
void TrimRight( );
void TrimRight(
TCHAR chTarget );
void TrimRight(
LPCTSTR lpszTargets );
Parameters
- chTarget
Specifies the target characters to be trimmed. - lpszTargets
Specifies a pointer to a string containing the target characters to be trimmed.
Example
CString strBefore; CString strAfter; strBefore = "Hockey is Best!!!!"; strAfter = strBefore; str.TrimRight('!'); _tprintf("Before: \"%s\"\n", (LPCTSTR) strBefore); _tprintf("After : \"%s\"\n\n", (LPCTSTR) strAfter); strBefore = "Hockey is Best?!?!?!?!"; strAfter = strBefore; str.TrimRight("?!"); _tprintf("Before: \"%s\"\n", (LPCTSTR) strBefore); _tprintf("After : \"%s\"\n\n", (LPCTSTR) strAfter);
In the first previous example, the string "Hockey is Best!!!!" becomes "Hockey is Best".
In the second previous example, the string "Hockey is Best?!?!?!?!" becomes "Hockey is Best".
Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afx.h
Platform: H/PC Pro, Palm-size PC, Pocket PC
See Also
CString::TrimLeft, CString::Mid, CString::Left, CString::Right, CString::MakeUpper, CString::MakeLower, CString::MakeReverse, CString::Format