What do ofTrim(), ofTrimBack() and ofTrimFront() do?

#1

Hi, I wonder what they do.
I tried passing a string to these functions but I don’t see any change to the string.

Here’s my sample code:

string str = "  hello world  ";
cout << strlen(str.c_str()) << endl;
ofTrim(str);
cout << strlen(str.c_str()) << endl;

And here’s the result I get:

15
15

What do these functions do?

#2

They remove spaces but they don’t modify the original and instead return a new string so you need to do

str = ofTrim(str);
1 Like
#3

Thank you! It works haha.