|
|
1.1 root 1: static char *sccsid = "@(#)gets.c 4.2 (Berkeley) 6/19/81";
2: #include <stdio.h>
3:
4: /*
5: * gets [ default ]
6: *
7: * read a line from standard input, echoing to std output
8: * if an error occurs just return "default"
9: * if no default and error exit abnormally
10: */
11: main(argc, argv)
12: int argc;
13: char *argv[];
14: {
15: char buf[BUFSIZ];
16:
17: setbuf(stdin, NULL);
18: if (gets(buf) == NULL || buf[0] < ' ') {
19: if (argc == 1)
20: exit(1);
21: strcpy(buf,argv[1]);
22: }
23: printf("%s\n", buf);
24: exit(0);
25: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.