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
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

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

synopsis

trim(s)
char s[];

description

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().

bugs

author

Jerry Leichter

#endif

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

#define EOS '\0'

trim(s)
char s[];
{ register char *p;
register int lim;

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


  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: http://www.os2museum.com/wp/mtswslnk/