I wrote a quick function to trim trailing spaces on a string without generating a new string...
Doing it on leading spaces is more complicated. I particularly don't want something that generates a new string. Something I can call like this:Code:void rtrim (char * s ) { int end; end = strlen(s) - 1; if (end >= 0 && s[end] == '\n') s[end] = '\0'; }
I can't be the first person to do this - rather than invent the wheel, does someone have code or a pointer to some code?Code:ltrim(somestring);
I'm thinking something that uses memmove() would be the solution...? Or perhaps there's a different technique...?



LinkBack URL
About LinkBacks




