home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 163_01 / gets.c < prev    next >
Text File  |  1988-01-31  |  512b  |  24 lines

  1. /*
  2. ** get a string from "stdin"
  3. ** terminate with \0
  4. */
  5. extern int *stdin, fgetc();
  6.  
  7. gets(s) char *s; {
  8.   int n, ch;
  9.   char *str;
  10.   str=s; /* save original value */
  11.   n = 256;
  12.   while(--n) {
  13.     ch=fgetc(stdin);
  14.     if(ch<0) {
  15.       *s='\0';
  16.       return 0;
  17.       }
  18.     if(ch=='\n') break;
  19.     *s++=ch;
  20.     }
  21.   *s='\0';
  22.   return str;
  23.   }
  24.