DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦743fda604⟧ TextFile

    Length: 394 (0x18a)
    Types: TextFile
    Notes: UNIX file
    Names: »fgets.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libc/stdio/fgets.c« 

TextFile

/*
 * Coherent Standard I/O Library
 * fgets -- read a string from input
 * file pointer leaving the trailing
 * newline character.
 */

#include <stdio.h>

char *
fgets(as, lim, iop)
char *as;
register lim;
FILE *iop;
{
	register c;
	register char *s;

	s = as;
	while (--lim > 0 && (c = getc(iop)) != EOF)
		if ((*s++ = c) == '\n')
			break;
	*s = 0;
	return (c==EOF && s==as ? NULL : as);
}