Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1exp 11/4/83; site ihuxl.UUCP Path: utzoo!linus!decvax!harpo!eagle!mhuxl!houxm!ihnp4!ihuxl!dcn From: dcn@ihuxl.UUCP Newsgroups: net.sources Subject: tec C source - fgets.c Message-ID: <729@ihuxl.UUCP> Date: Fri, 11-Nov-83 17:29:31 EST Article-I.D.: ihuxl.729 Posted: Fri Nov 11 17:29:31 1983 Date-Received: Sun, 13-Nov-83 07:55:29 EST Organization: AT&T Bell Labs, Naperville, Il Lines: 24 /* 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) ; }