added LIBC_SCCS condition for sccs ids
[unix-history] / usr / src / lib / libc / stdio / fgets.c
CommitLineData
2ce81398
DS
1#if defined(LIBC_SCCS) && !defined(lint)
2static char sccsid[] = "@(#)fgets.c 5.2 (Berkeley) %G%";
3#endif LIBC_SCCS and not lint
b8f253e8 4
0175c543
BJ
5#include <stdio.h>
6
7char *
8fgets(s, n, iop)
9char *s;
10register FILE *iop;
11{
12 register c;
13 register char *cs;
14
15 cs = s;
41e01b3e 16 while (--n>0 && (c = getc(iop)) != EOF) {
0175c543
BJ
17 *cs++ = c;
18 if (c=='\n')
19 break;
20 }
41e01b3e 21 if (c == EOF && cs==s)
0175c543
BJ
22 return(NULL);
23 *cs++ = '\0';
24 return(s);
25}