• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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