isblank() implementation.
[minix.git] / lib / libc / stdio / gets.c
blob53150b0cd550f24e0bb3ec9ce0788481f458eb97
1 /*
2 * gets.c - read a line from a stream
3 */
4 /* $Header$ */
6 #include <stdio.h>
8 char *
9 gets(char *s)
11 register FILE *stream = stdin;
12 register int ch;
13 register char *ptr;
15 ptr = s;
16 while ((ch = getc(stream)) != EOF && ch != '\n')
17 *ptr++ = ch;
19 if (ch == EOF) {
20 if (feof(stream)) {
21 if (ptr == s) return NULL;
22 } else return NULL;
25 *ptr = '\0';
26 return s;