Discussion:
CString::TrimRight does not work properly
(too old to reply)
Jewel
2003-11-09 08:33:29 UTC
Permalink
Hello,

I am facing a problem with the CString::TrimRight function. When I try to trim
the extension from a filename using TrimRight(".exe"), some trailing characters
get trimmed too. For example, "Cliente.exe" gets converted to "Client" instead
of "Cliente". Why does this happen and what can I do to resolve the problem?

Any help would be greatly appreciated!!

Thanks


-----------------------------------------------------
This message was posted using http://www.gdse.com/
David Lowndes
2003-11-09 10:15:47 UTC
Permalink
Post by Jewel
I am facing a problem with the CString::TrimRight function. When I try to trim
the extension from a filename using TrimRight(".exe"), some trailing characters
get trimmed too. For example, "Cliente.exe" gets converted to "Client" instead
of "Cliente". Why does this happen and what can I do to resolve the problem?
I think that TrimRight removes all occurrences of those characters,
rather than the exact match of them as you seem to assume. You
probably want to use the Left() method to remove the last 4
characters.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
lava_sdb
2003-11-09 11:57:11 UTC
Permalink
Wrong usage!!
If you want get the SubString, you should use the member function:
left(),mid(),or right(); You can using find() find out the substring's
position.
Post by Jewel
Hello,
I am facing a problem with the CString::TrimRight function. When I try to trim
the extension from a filename using TrimRight(".exe"), some trailing characters
get trimmed too. For example, "Cliente.exe" gets converted to "Client" instead
of "Cliente". Why does this happen and what can I do to resolve the problem?
Any help would be greatly appreciated!!
Thanks
-----------------------------------------------------
This message was posted using http://www.gdse.com/
Loading...