/*
Due to some braindamaged program requirements,
the following funciton must copy from a FILE
to an ostream.  Why does it fail to work.
*/

#include <stdio.h>
#include <iostream.h>

void copy_it(
    FILE *in_file,	/* Input file */
    ostream &out_file	/* Output file */
)
{
    int ch;	/* Current char */

    while (1) {
	ch = fgetc(in_file);
	if (ch == EOF)
	    break;
	out_file << ch;
    }
}

int main()
{
    FILE *in_file = fopen("in.txt");
    ofstream out_file("out.txt");

    if (in_file == NULL) {
	cerr << "Error: Could not open input\n";
	exit (8);
    }
    if (out_file.bad()) {
	cerr << "Error: Could not open output\n";
	exit (8);
    }
    copy_it(in_file, out_file);
    fclose(in_file);
    return (0);
}


