BSD 2 development
[unix-history] / src / gets.c
CommitLineData
ffcdbf5b
BJ
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 */
12main(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}