1*3907Swnj static char *sccsid = "@(#)gets.c 4.2 (Berkeley) 06/19/81"; 21024Sbill #include <stdio.h> 31024Sbill 41024Sbill /* 51024Sbill * gets [ default ] 61024Sbill * 71024Sbill * read a line from standard input, echoing to std output 81024Sbill * if an error occurs just return "default" 91024Sbill * if no default and error exit abnormally 101024Sbill */ main(argc,argv)111024Sbillmain(argc, argv) 121024Sbill int argc; 131024Sbill char *argv[]; 141024Sbill { 151024Sbill char buf[BUFSIZ]; 161024Sbill 17*3907Swnj setbuf(stdin, NULL); 181024Sbill if (gets(buf) == NULL || buf[0] < ' ') { 191024Sbill if (argc == 1) 201024Sbill exit(1); 211024Sbill strcpy(buf,argv[1]); 221024Sbill } 231024Sbill printf("%s\n", buf); 241024Sbill exit(0); 251024Sbill } 26