|
-
May 10th, 2009, 06:16 AM
#1
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|