Jump to content

Talk:Trimming (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Paddy3118 (talk | contribs) at 05:29, 10 October 2007 (Keep the Functions, Remove Just Code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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)[reply]

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)[reply]
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)[reply]

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)); }

Keep the functions. Remove just code

Hi, I think you should remove the "other languages which don't have trim functions" section. They don't have trim or a close analogue, so they should be trimmed. It is superfluous text at the end of the article that happens to take up more than half the article that is supposed to be on trim rather than what is not trim. It is quite easy to define trim-like and, by omision what is not trim-like. That section becomes a tutorial on how to write trim in other languages and should be removed or moved to this talk page. Please refer to this.