Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Just a quick one

just a quick question,

            CString message;
            message.Format( "Some sort of text" );

how would i trim the last 9 chars off of this text? probibly something simple... lol

i tried:

            message.TrimRight (9);

didn't work
0
123webserver
Asked:
123webserver
  • 2
1 Solution
 
stsanzCommented:
The TrimLeft/Right functions trim only the whitespace characters off.

Try:
message = message.Left(message.length() - 9) ;

0
 
stsanzCommented:
Oops, I meant:
message = message.Left(message.GetLength() - 9) ;


0
 
cindy_kCommented:
How about this:

int LenString;
CString ShorterString;

LenString = message.GetLength();  //I did this to make is generic

if (LenString > 9)
     ShorterString = message.Left(LenString - 9);

//or if you want the other side
     ShorterString = message.Right(LenString - 9);

0
 
123webserverAuthor Commented:
message = message.Left(message.GetLength() - 9) ;

worked great, knew it was something simple... lol

thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now