2.2.3.15.40 string::TrimRight

Description

Trim trailing whitespace characters from the string. It removes trailing newline, space, and tab characters.


Remove a particular character from the end of a string.


Remove a group of particular characters from the end of the string.

Syntax

void TrimRight( )


void TrimRight( char chTarget )


void TrimRight( LPCSTR lpszTargets )

Parameters

chTarget
[input]character to be trimmed.


lpszTargets
[input] A pointer to a string containing the target characters to be trimmed.

Return

None.


None.


None.

Examples

EX1

//Trim right whitespace characters from the string
void string_TrimRight_ex1()
{
    
    string str="Hello World    ";
    str.TrimRight();
    out_str(str);//"Hello World"
}


EX2

//Removes a particular character from the end of the string
void string_TrimRight_ex2()
{
    string str="aaabbbcccaaa";
    str.TrimRight('a');
    out_str(str);//"aaabbbccc" 
}


EX3

//Removes a group of particular characters from the end of the string
void string_TrimRight_ex3()
{
    string str = _L("**##Origin is good!*****   ######"); 
    str.TrimRight("* #");                           
    out_str(str);//"**##Origin is good!"            
}

Remark

See Also

string::Format, string::Left, string::MakeLower, string::MakeUpper, string::Mid, string::Right

Header to Include

origin.h