home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / util / lines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  306 b   |  22 lines

  1. /*
  2.  *    lines -- send newlines to the output stream
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. int
  9. lines(n, fp)
  10. int n;
  11. FILE *fp;
  12. {
  13.     register int i;
  14.  
  15.     for (i = 0; i < n; ++i)
  16.         if (putc('\n', fp) == EOF && ferror(fp))
  17.             break;
  18.  
  19.     /* return number of newlines emitted */
  20.     return (i);
  21. }
  22.