/************************************************************* * File: lib/fgets.c * Purpose: Part of C runtime library * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970304 Start of revision history */ #include /************************************************************* * char *fgets(dst,max,fp) get string from stream */ char *fgets(dst,max,fp) char *dst; int max; FILE *fp; { int c,n; char *p; /* get max bytes or upto a newline */ for (p=dst,max--;max>0;max--) { if ((c=getc(fp)) == EOF) break; *p++ = c; if (c == '\n') break; } *p = 0; if (p == dst) return(0); return(p); }