home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 387b.lha / dice_v2.02 / lib / stdio / gets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  378 b   |  32 lines

  1.  
  2. /*
  3.  *  GETS.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  *
  7.  *  buf = gets(buf)
  8.  */
  9.  
  10. #include <stdio.h>
  11.  
  12. char *
  13. gets(buf)
  14. char *buf;
  15. {
  16.     int c;
  17.     int cnt = 0;
  18.     char *base = buf;
  19.  
  20.     while ((c = getc(stdin)) != EOF) {
  21.     *buf++ = c;
  22.     if (c != '\n' && cnt < BUFSIZ) {
  23.         ++cnt;
  24.         continue;
  25.     }
  26.     buf[-1] = 0;
  27.     return(base);
  28.     }
  29.     return(NULL);
  30. }
  31.  
  32.