Solved

Just a quick one

Posted on 2003-10-28
4
218 Views
Last Modified: 2012-05-04
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
Comment
Question by:123webserver
  • 2
4 Comments
 
LVL 6

Expert Comment

by:stsanz
ID: 9634531
The TrimLeft/Right functions trim only the whitespace characters off.

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

0
 
LVL 6

Accepted Solution

by:
stsanz earned 25 total points
ID: 9634535
Oops, I meant:
message = message.Left(message.GetLength() - 9) ;


0
 
LVL 3

Expert Comment

by:cindy_k
ID: 9634546
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
 

Author Comment

by:123webserver
ID: 9634570
message = message.Left(message.GetLength() - 9) ;

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

thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now