1: #include <stdio.h>
   2: 
   3: /*
   4:  * getstr - read a line into buf from file fd.  At most max characters
   5:  *  are read.  getstr returns the length of the line, not counting
   6:  *  the newline.  Note that if a file doesn't end in a newline, the
   7:  *  characters between the last newline and the end of the file
   8:  *  are never seen.
   9:  */
  10: 
  11: getstr(buf, max, fd)
  12: register char *buf;
  13: int max;
  14: FILE *fd;
  15:    {
  16:    register int c, l;
  17: 
  18:    l = 0;
  19:    while ((c = getc(fd)) != '\n') {
  20:       if (c == EOF)
  21:          return -1;
  22:       *buf++ = c;
  23:       if (++l >= max)
  24:          break;
  25:       }
  26:    return l;
  27:    }

Defined functions

getstr defined in line 11; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 470
Valid CSS Valid XHTML 1.0 Strict