Talk:Trimming (computer programming)
Appearance
C/C++ example needs actual code
The C/C++ example isn't too illustrative of the theory behind trimming a string in C. Perhaps an example that contains the actual code would be more appropriate. (I want to see some loops in there!) --indil 20:55, 19 July 2006 (UTC)
- I went for a brief overview and stuck with the simplest functions/libraries/implementations I could find. Please feel free to add some code :) โPengo talk ยท contribs 13:02, 23 July 2006 (UTC)
- I've changed the code for the C example. I believe the old example would have leaked memory - for processing large amounts of data, this could cause problems! On a side note, could someone check to make sure I haven't done something dumb while writing this (it compiled and worked in VC++) --Portej 07:29, 26 September 2007 (UTC)
in AWK better to use those command:
function ltrim(s) { sub(/^ */, "", s); return s }
function rtrim(s) { sub(/ *$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }