void TrimRight( );
void CString::TrimRight( TCHAR chTarget );
void CString::TrimRight( LPCTSTR lpszTargets );
Parameters
chTarget
The target characters to be trimmed.
lpszTargets
A pointer to a string containing the target characters to be trimmed.
Remarks
Call the version of this member function with no parameters to trim trailing whitespace characters from the string. When used with no parameters, TrimRight removes trailing newline, space, and tab characters from the string.
Use the versions of this function that accept parameters to remove a particular character or a particular group of characters from the end of a string.
Example
CString strBefore;
CString strAfter;
strBefore = "Hockey is Best!!!!";
strAfter = strBefore;
str.TrimRight('!');
printf("Before: \"%s\"\n", (LPCTSTR) strBefore);
printf("After : \"%s\"\n\n", (LPCTSTR) strAfter);
strBefore = "Hockey is Best?!?!?!?!";
strAfter = strBefore;
str.TrimRight("?!");
printf("Before: \"%s\"\n", (LPCTSTR) strBefore);
printf("After : \"%s\"\n\n", (LPCTSTR) strAfter);
In the first example above, the string reading, "Hockey is Best!!!!" becomes "Hockey is Best".
In the second example above, the string reading, , "Hockey is Best?!?!?!?!" becomes "Hockey is Best".
For more information, see Strings Topics in Visual C++ Programmer’s Guide
CString Overview | Class Members | Hierarchy Chart
See Also CString::TrimLeft, CString::Mid, CString::Left, CString::Right, CString::MakeUpper, CString::MakeLower, CString::MakeReverse, CString::Format