473,511 Members | 16,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trim heading and trailing space

Hello everyone,
I think in built-in C/C++ functions, there is no direct function call to
trim heading and trailing space characters, right? So, we have to implement
it manually by iterating the string to check character one by one.

Support not using MFC.
thanks in advance,
George
Oct 21 '07 #1
6 2986
>I think in built-in C/C++ functions, there is no direct function call to
>trim heading and trailing space characters, right? So, we have to implement
it manually by iterating the string to check character one by one.

Support not using MFC.
George,

You're posing in a .Net group, so if you're using String ^, there is a
Trim method already.

If you're using native C++ using std:string, you might want to have a
look at the Boost library facilities which I believe have trim
facilities
(http://www.boost.org/doc/html/string...html#id1638126)

MFC's CString has its own Trim method built-in.

Dave
Oct 21 '07 #2
Thanks Dave,
I think there is no built-in trim functions in even STL string. Right?
regards,
George

"David Lowndes" wrote:
I think in built-in C/C++ functions, there is no direct function call to
trim heading and trailing space characters, right? So, we have to implement
it manually by iterating the string to check character one by one.

Support not using MFC.

George,

You're posing in a .Net group, so if you're using String ^, there is a
Trim method already.

If you're using native C++ using std:string, you might want to have a
look at the Boost library facilities which I believe have trim
facilities
(http://www.boost.org/doc/html/string...html#id1638126)

MFC's CString has its own Trim method built-in.

Dave
Oct 21 '07 #3
>I think there is no built-in trim functions in even STL string. Right?

None that I'm aware of - hence the Boost suggestion. There's an
article on CodeProject too -
http://www.codeproject.com/vcpp/stl/stdstringtrim.asp

Dave
Oct 21 '07 #4
Hi Dave,
It is implemented by find_first_not_of and find_last_not_of of STL string,
no built-in functions.
regards,
George

"David Lowndes" wrote:
I think there is no built-in trim functions in even STL string. Right?

None that I'm aware of - hence the Boost suggestion. There's an
article on CodeProject too -
http://www.codeproject.com/vcpp/stl/stdstringtrim.asp

Dave
Oct 21 '07 #5
>It is implemented by find_first_not_of and find_last_not_of of STL string,
>no built-in functions.
Yes, that's what the CodeProject article uses.

Dave
Oct 21 '07 #6
Thanks Dave,
I think there is no built-in trim function and the method described in
CodeProject seems to be the best way.
regards,
George

"David Lowndes" wrote:
It is implemented by find_first_not_of and find_last_not_of of STL string,
no built-in functions.

Yes, that's what the CodeProject article uses.

Dave
Oct 21 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1839
by: Shabam | last post by:
Is there a function in dotnet that allows me to trim user input so that: 1) It gets rid of leading/trailing spaces, tabs, newlines and whatever other non-printing characters 2) Gets rid of all...
3
12962
by: jose luis fernandez diaz | last post by:
Hi, Does any know a algorithm to strip heading and leading blank in a string ? Tnansk, Jose Luis
8
17718
by: DrBob | last post by:
gcc 3.3 MAC OS X. I have a string that has trailing spaces in it that I want removed. So i have a variable: string x("abcd "); x.trim() isn't an implemented method. Is there a method I...
5
33273
by: Alex Vassiliev | last post by:
Hi all. Just wanted to share two handy RegEx expressions to strips leading and trailing white-space from a string, and to replace all repeated spaces, newlines and tabs with a single space. *...
3
10677
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
9
6264
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
7
4201
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
1
123161
by: Konstantinos Pachopoulos | last post by:
Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert " asdf " to "asdf"? Thnx
121
4993
by: swengineer001 | last post by:
Just looking for a few eyes on this code other than my own. void TrimCString(char *str) { // Trim whitespace from beginning: size_t i = 0; size_t j; while(isspace(str)) {
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.