开发者

Am I missing something here ? XD TrimRight does not seem to want to work

开发者 https://www.devze.com 2023-02-24 23:11 出处:网络
Ok, here is the small portion of开发者_JAVA技巧 code to demonstrate: CString txt = _T(\"Hello World\");

Ok, here is the small portion of开发者_JAVA技巧 code to demonstrate:

CString txt = _T("Hello World");
CString txt2 = txt;
txt2.TrimRight('W');
AfxMessageBox(txt2);

The output is "Hello World".

What am I not getting right ?


The call txt2.TrimRight('W'); removes all characters 'W' from the right side of the string. Since "Hello World" does not end in 'W' nothing is trimmed at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消