CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    26

    Talking Removing characters from a string [Solved]

    Okay, what I basically want to do is to remove the two last characters from my string witch is a
    tab and a newline character, but I think that doesn't matter, because they are always at the end of
    the string. I got a code already, but it doesn't work correctly.

    Code:
        string::size_type pos = 0;
        while ((pos = txt.find_first_of("\n\t", pos) != string::npos))
            txt.erase(pos, 1);
    
        return txt;
    It seems like that code removes everything except the first character.
    Thanks in advance
    Last edited by WirelessDice; May 10th, 2009 at 07:36 AM. Reason: *solved*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured