Listing 13 Uses file streams to copy files

// copy4.cpp: Copy one file to another
#include <iostream.h>
#include <fstream.h>  // Required for file streams
#include <std1ib.h>

main(int argc, char *argv[])
{
   if (argc == 3)
   {
      ifstream inf(argv [1] );
      ofstream outf(argv[2]);
      if (inf && outf)
      {
         char c;

         while (inf.get(c))
            outf.put(c);

         return EXIT_SUCCESS;
      } // Streams destroyed by this point
   }
   return EXIT_FAILURE;
}

// End of File