home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_07 / 1107110a < prev    next >
Text File  |  1993-04-29  |  658b  |  37 lines

  1. // copy5.cpp: Copy one file to another
  2. #include <iostream.h>
  3. #include <fstream.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. main(int argc, char *argv[])
  8. {
  9.     ifstream inf;
  10.     ofstream outf;
  11.  
  12.     // Open optional input file
  13.     if (argc > 1)
  14.         inf.open(argv[1]);
  15.     else
  16.         inf.attach(fileno(stdin));
  17.         
  18.     // Open optional output file
  19.     if (argc > 2)
  20.         outf.open(argv[2]);
  21.     else
  22.         outf.attach(fileno(stdout));
  23.  
  24.     if (inf && outf)
  25.     {
  26.         char c;
  27.  
  28.         while (inf.get(c))
  29.               outf.put(c);
  30.  
  31.         return EXIT_SUCCESS;
  32.     }
  33.     else
  34.         return EXIT_FAILURE;
  35. }
  36.  
  37.