home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libc / dogets.c < prev    next >
Text File  |  1992-04-18  |  364b  |  19 lines

  1. /*
  2.  * dogets - do the gets hack on a counted string: given a string and length
  3.  *    pointer, delete any trailing newline and adjust the length to match.
  4.  */
  5.  
  6. char *
  7. dogets(s, lenp)
  8. register char *s;
  9. register int *lenp;
  10. {
  11.     register char *nlp = s + *lenp - 1;
  12.  
  13.     if (*lenp > 0 && *nlp == '\n') {
  14.         *nlp = '\0';            /* stomp innocent newline */
  15.         --*lenp;
  16.     }
  17.     return s;
  18. }
  19.