Commit | Line | Data |
---|---|---|
b8f253e8 KM |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)gets.c 5.1 (Berkeley) %G%"; | |
3 | #endif not lint | |
4 | ||
c3d4b9ff BJ |
5 | #include <stdio.h> |
6 | ||
7 | char * | |
8 | gets(s) | |
9 | char *s; | |
10 | { | |
11 | register c; | |
12 | register char *cs; | |
13 | ||
14 | cs = s; | |
41e01b3e | 15 | while ((c = getchar()) != '\n' && c != EOF) |
c3d4b9ff | 16 | *cs++ = c; |
41e01b3e | 17 | if (c == EOF && cs==s) |
c3d4b9ff BJ |
18 | return(NULL); |
19 | *cs++ = '\0'; | |
20 | return(s); | |
21 | } |