home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / RMTRAIL.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  926b  |  43 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  Originally published as part of the MicroFirm Function Library
  5. **
  6. **  Copyright 1986, S.E. Margison
  7. **  Copyright 1989, Robert B.Stout
  8. **
  9. **  The user is granted a free limited license to use this source file
  10. **  to create royalty-free programs, subject to the terms of the
  11. **  license restrictions specified in the LICENSE.MFL file.
  12. **
  13. **  remove trailing whitespace from a string
  14. */
  15.  
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include "snip_str.h"
  19.  
  20. #if defined(__cplusplus) && __cplusplus
  21.  extern "C" {
  22. #endif
  23.  
  24. char *rmtrail(char *str)
  25. {
  26.       int i;
  27.  
  28.       if (str && 0 != (i = strlen(str)))
  29.       {
  30.             while (--i >= 0)
  31.             {
  32.                   if (!isspace(str[i]))
  33.                         break;
  34.             }
  35.             str[++i] = NUL;
  36.       }
  37.       return str;
  38. }
  39.  
  40. #if defined(__cplusplus) && __cplusplus
  41.  }
  42. #endif
  43.