×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Removal of Spaces from Input strings

Removal of Spaces from Input strings

Removal of Spaces from Input strings

(OP)
Help

Can anyone tell me how I can strip the initial spaces from an input string and store the remaining string. For example if "<space><space>Hello<space>World" is entered. I need to strip the first 2 spaces from the text to leave me with"Hello<space>World".
The code needs to be written as a void method ie
void TrimFront(AnsiString &Str)
and called by the main command "TrimFront(Line)" where Line is the original input String.

Thanks in advance

RE: Removal of Spaces from Input strings

Why don't u just use the AnsiString Trim function or TrimLeft or TrimRight

RE: Removal of Spaces from Input strings

(OP)
if u reading from a file and you have the ifstream in("file.txt")
then in.get();and againin.get() would remove the two spaces and place the cursors before h of hello world. then you acn use in.getline to take in the rest og the string with the spaces without providing any delimiter. if instead of fstream u use the input directly from the screen u can use cin.get() and cin.getline() in respective places where u used the 'in' of the fstream before before..
take care and have a nice time

RE: Removal of Spaces from Input strings

do the trim, Like this:

AnsiString Hello = "Hello World";

Trim (Hello);

thats all there is to it

Cyprus

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close