Solved

Just a quick one

Posted on 2003-10-28
4
221 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

820 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