// copy5.cpp: Copy one file to another
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>

main(int argc, char *argv[])
{
    ifstream inf;
    ofstream outf;

    // Open optional input file
    if (argc > 1)
        inf.open(argv[1]);
    else
        inf.attach(fileno(stdin));
        
    // Open optional output file
    if (argc > 2)
        outf.open(argv[2]);
    else
        outf.attach(fileno(stdout));

    if (inf && outf)
    {
        char c;

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

        return EXIT_SUCCESS;
    }
    else
        return EXIT_FAILURE;
}

