home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / unixlib36d / src / stdio / c / gets < prev    next >
Encoding:
Text File  |  1994-03-08  |  400 b   |  23 lines

  1. static char sccs_id[] = "@(#) gets.c 1.1 " __DATE__ " HJR";
  2.  
  3. /* gets.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <stdio.h>
  6.  
  7. __STDIOLIB__
  8.  
  9. char *
  10. gets (register char *_s)
  11. {
  12.   register FILE *f = stdin;
  13.   register char *s = _s;
  14.   register int c = 0;
  15.  
  16.   while ((c = getc (f)) >= 0)
  17.     if ((*s++ = c) == '\n')
  18.       break;
  19.  
  20.   (c == '\n') ? (*--s = 0) : (*s = 0);
  21.   return ((c < 0 && s == _s) ? 0 : _s);
  22. }
  23.