Category : C Source Code
Archive   : CSRC2.ZIP
Filename : TRIM.C

Output of file : TRIM.C contained in archive : CSRC2.ZIP
* t r i m . c



title trim Trim Trailing Whitespace From a String
index Trim trailing whitespace from a string


char s[];


trim() trims all trailing whitespace from the string passed. Note
that the actual string passed is modified.

"Whitespace-ness" is determined by the function isspace().



Jerry Leichter


* Edit history
* 0.0 19-May-81 JSL Invention
* 1.0 14-Jul-82 JSL iswhite() ==> isspace()

#define EOS '\0'

char s[];
{ register char *p;
register int lim;

for (p=s+(lim = strlen(s)); isspace(*--p) && --lim >= 0; )
*(p+1) = EOS;

  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : TRIM.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: