trim heading and trailing space

G

Guest

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
 
D

David Lowndes

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_algo/usage.html#id1638126)

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

Dave
 
G

Guest

Thanks Dave,


I think there is no built-in trim functions in even STL string. Right?


regards,
George
 
G

Guest

Hi Dave,


It is implemented by find_first_not_of and find_last_not_of of STL string,
no built-in functions.


regards,
George
 
D

David Lowndes

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top