Solved

Just a quick one

Posted on 2003-10-28
4
215 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
Comment Utility
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
Comment Utility
Oops, I meant:
message = message.Left(message.GetLength() - 9) ;


0
 
LVL 3

Expert Comment

by:cindy_k
Comment Utility
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
Comment Utility
message = message.Left(message.GetLength() - 9) ;

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

thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

11 Experts available now in Live!

Get 1:1 Help Now