Removing whitespace

For some odd reason, my function isn't removing any whitespace. Can anyone see why?
1
2
3
4
5
6
7
8
9
string Manage::RemoveWhite(string &str) {
    string final;
    for(unsigned int i = 0; i < str.length(); i++) {
        if(str[i] != ' ') {
            final += str[i];
        }   
    }
    return final;
}


How its used: cout << line << " - " << RemoveWhite(temp) << endl;
I think that should work - are you sure your problem isn't in how it's being used? Does temp perhaps have tab characters that you are mistaking for spaces?

--Rollie
now that i think of it, yes, it is a tab space, but how would i remove that?
if(str[i] != ' ' && str[i] != '\t') {

:)

--Rollie
Ahh, thank you, that did the trick!
Topic archived. No new replies allowed.