// Justin C. Miller
// University of Wisconsin Oshkosh
// Made for: http://www.geocities.com/neonprimetime.geo/index.html
// Date: 2001
// Borland Builder 4.0
// ifstream, ofstream, open, close, eof
#include
#include // must include fstream.h
// in order to use data files
int main()
{
ifstream inFile ; // opens an input stream called inFile
ofstream OutFile ; // opens an output stream called OutFile
inFile.open("mydata.dat") ; // opens data file to read to "mydata.dat"
OutFile.open("copyofdata.dat") ; // opens data file to write to
int x ; // a temporary variable to read data into
// this loops runs while you are not at the end of the file
while(!inFile.eof()) // eof() checks if you are at the end of the data file
{
inFile >> x ; // reads data from the inFile, puts it into x
OutFile >> x ; // puts the value of x in the OutFile
}
return 0 ;
}
// EXAMPLE
// mydata.dat looks like this --> 1 9 12 7 4
// copyofdata.dat is first empty
//
// execute main
//
// mydata.dat looks the same --> 1 9 12 7 4
// copyofdata.dat is now an exact copy --> 1 9 12 7 4
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)