Revision: 9228
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 26, 2008 21:29 by iTony
Initial Code
void trim(char *s, const int len) { int end = len - 1; int start = 0; int i = 0; while ((start < len) && (s[start] <= ' ')) { start++; } while ((start < end) && (s[end] <= ' ')) { end--; } if (start > end) { memset(s, '\0', len); return; } for (i = 0; (i + start) <= end; i++) { s[i] = s[start + i]; } memset((s + i), '\0', len - i); }
Initial URL
http://blog.srikanths.net/2008/10/trim-for-c.html
Initial Description
Initial Title
Trim function for strings in C++
Initial Tags
c
Initial Language
C++