home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / gets.c < prev    next >
C/C++ Source or Header  |  1992-09-17  |  368b  |  25 lines

  1. #include <stdio.h>
  2. #include <assert.h>
  3.  
  4. char *gets(data)
  5.     register char *data;
  6.     {
  7.     register char *p = data;
  8.     register int c;
  9.  
  10.     assert((data != NULL));
  11.     
  12.     while(((c = getc(stdin)) != EOF) && (c != '\n'))
  13.         {
  14.         if(c == '\b')
  15.             {
  16.             if(p > data)
  17.                 --p;
  18.             }
  19.         else
  20.             *p++ = c;
  21.         }
  22.     *p = '\0';
  23.     return(((c == EOF) && (p == data)) ? NULL : data);  /* NULL == EOF */
  24.     }
  25.