/*+ $Header: /home/aggarwal/lsrc/nocol/src/lib/RCS/fgetline.c,v 1.2 1994/01/03 23:31:55 aggarwal Exp $ ** FUNCTION: ** ** Analogous to the stdio function 'fgets' but returns the number ** characters read instead of the pointer to the string read. ** Leaves the '\n' character and appends a null '\0' at end of string. **/ #include int fgetLine(fp, s,lim) FILE *fp; char *s; int lim; { register int c,i; i=0; while (--lim>0 && (c=getc(fp)) != EOF && c!='\n') s[i++]=c; if ( c== '\n' ) s[i++]=c; s[i]='\0'; return(i); }