|
|
1.1 root 1: /*
2: * Coherent Standard I/O Library
3: * fgets -- read a string from input
4: * file pointer leaving the trailing
5: * newline character.
6: */
7:
8: #include <stdio.h>
9:
10: char *
11: fgets(as, lim, iop)
12: char *as;
13: register lim;
14: FILE *iop;
15: {
16: register c;
17: register char *s;
18:
19: s = as;
20: while (--lim > 0 && (c = getc(iop)) != EOF)
21: if ((*s++ = c) == '\n')
22: break;
23: *s = 0;
24: return (c==EOF && s==as ? NULL : as);
25: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.