//----------------------------------------------------------------------
// This program opens a pair of files -- one for reading, the other for 
// writing.  It reads two integers and a floating-point value out of the
// input file and writes them to the output file.
//
// Written by:  Brad Richards,  2/1/98
//
// Inputs:	Two integers and a float from "datafile.txt"
// Outputs:	Two integers and a float
//
// Assumptions:  The file "datafile.txt" exists and contains at least
//	two integers and a floating-point value.
//----------------------------------------------------------------------

#include <fstream.h>		// Needed for file I/O
#include <iostream.h>		// We're also using cout


int main()
{
    ifstream theInputFile;	// Variable "pointing to" input stream
    ofstream theOutputFile;	// Variable "pointing to" output stream
    int i;			// i, j, f hold values temporarily
    int j;
    float f;

	// We have to associate the input and output stream variables
	// with the names of actual FILES before we can use them.  The
	// input file must already exist.  The output will be created
	// if it doesn't exist yet.

	theInputFile.open("datafile.txt");	// Open input file
	theOutputFile.open("output.txt");	// Open output file

	// Now we can use the variables just like cin and cout

	theInputFile >> i >> j >> f;
	cout << "So far, so good..." << endl;
	cout << "read: " << i << " " << j << " " << f << endl;
	theOutputFile << "I just read:" << endl;
	theOutputFile << i << " " << j << " " << f << endl;

	return 0;
}

