Uninitialized vector entry?
[minix3.git] / lib / stdio / fgets.c
blob1072a736b60e54aaafad8d324df01e6c463a5aa8
1 /*
2 * fgets.c - get a string from a file
3 */
4 /* $Header$ */
6 #include <stdio.h>
8 char *
9 fgets(char *s, register int n, register FILE *stream)
11 register int ch;
12 register char *ptr;
14 ptr = s;
15 while (--n > 0 && (ch = getc(stream)) != EOF) {
16 *ptr++ = ch;
17 if ( ch == '\n')
18 break;
20 if (ch == EOF) {
21 if (feof(stream)) {
22 if (ptr == s) return NULL;
23 } else return NULL;
25 *ptr = '\0';
26 return s;