home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / gets.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  454b  |  26 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #include <retrofit.h>
  3. #include <stdio.h>
  4.  
  5. /*
  6.  * gets [ default ]
  7.  *
  8.  *    read a line from standard input, echoing to std output
  9.  *    if an error occurs just return "default"
  10.  *    if no default and error exit abnormally
  11.  */
  12. main(argc, argv)
  13.     int argc;
  14.     char *argv[];
  15. {
  16.     char buf[BUFSIZ];
  17.     
  18.     if (gets(buf) == NULL) {
  19.         if (argc == 1)
  20.             exit(1);
  21.         buf[0] = 0;
  22.     }
  23.     printf("%s\n", buf);
  24.     exit(0);
  25. }
  26.