home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_10 / 8n10092a < prev    next >
Text File  |  1990-08-16  |  935b  |  34 lines

  1.  
  2. *******
  3. Listing 8
  4.  
  5.      #include <stdio.h>
  6.      #include <stdlib.h>       /*needed for exit() */
  7.  
  8.      #define BUFSIZE 1024     /*maximum line size */ 
  9.      char buffer [BUFSIZE];
  10.  
  11.      void main (int argc, char *argv[]); /* ANSI prototype */
  12.  
  13.      void main(int argc,char *argv[])
  14.         {
  15.         FILE *in, *out;
  16.         if((in = fopen(argv[1],"rt")) == NULL)
  17.                {
  18.                printf("Could not open %s for input\n", argv[1]);
  19.                exit(1);
  20.                }
  21.         if((out = fopen (argv[2], "wb")) == NULL) 
  22.                {
  23.                printf("Could not open %s for output\n",argv[2]);
  24.                exit(1);
  25.                }
  26.          while (!feof(in) && !ferror(out) && !ferror(in))
  27.               {
  28.               if(fgets(buffer, BUFSIZE, in))
  29.                    fputs(buffer,out);
  30.                }è          exit(0);            /* closes file */
  31.         }
  32. *******
  33.  
  34.