Listing 8

#include <stdio.h>
#include <stdlib.h>       /*needed for exit() */

#define BUFSIZE 1024     /*maximum line size */
char buffer [BUFSIZE];

void main (int argc, char *argv[]); /* ANSI prototype */

void main(int argc,char *argv[])
   {
   FILE *in, *out;
   if((in = fopen(argv[1],"rt")) == NULL)
         {
         printf("Could not open %s for input\n", argv[1]);
         exit(1);
         }
   if((out = fopen (argv[2], "wb")) == NULL)
         {
         printf("Could not open %s for output\n",argv[2]);
         exit(1);
         }
   while (!feof(in) && !ferror(out) && !ferror(in))
        {
        if(fgets(buffer, BUFSIZE, in))
            fputs(buffer,out);
         }
    exit(0);             /* closes file */
  }