tec C source - fgets.c

dcn at ihuxl.UUCP dcn at ihuxl.UUCP
Sat Nov 12 08:29:31 AEST 1983


/* fgets - read a line from a file. (returns NULL at eof) */

#include "stdio.h"

char *fgets(line, maxline, input)
char *line ;
int maxline ;
FILE *input ;
{
	int c ;
	char *start_line ;

	start_line = line;

	while( --maxline>0 && (c=agetc(input)) != EOF )
		if( (*line++ = c) == NL )
			break ;

	*line = 0 ;
	if( c == EOF && line == start_line )
		return(NULL) ;
	return(line) ;
}



More information about the Comp.sources.unix mailing list