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

  1. /*
  2.  *    fcopy -- copy input stream (fin) to output stream
  3.  *    (fout) and return an indication of success or failure
  4.  */
  5.  
  6. #include <stdio.h>
  7.  
  8. #define BUFLEN    1024
  9.  
  10. int
  11. fcopy(fin, fout)
  12. FILE *fin, *fout;
  13. {
  14.     int errcount = 0;
  15.     char line[BUFLEN];
  16.     register char *s;
  17.  
  18.     while ((s = fgets(line, BUFLEN, fin)) != NULL)
  19.         if (fputs(s, fout) == EOF)
  20.             ++errcount;
  21.     if (ferror(fin))
  22.         ++errcount;
  23.     return (errcount);    /* 0 if all went well */
  24. }
  25.