/* simple code to read from an input file and then write to an output file. */ #include #include using namespace::std; int main() { ifstream in_file; ofstream out_file; int r,s,t; // open input and output files: in_file.open("myjunk.dat"); out_file.open("example_out.dat"); // checking file is open for business: if ( in_file.is_open() ) { while(! in_file.eof() ) // still stuff to read { in_file >> r >> s >> t; out_file << "first col = " << r << "\t 2nd col " << s << "\t 3rd col = " << t << endl; } } in_file.close(); // good practice out_file.close(); // good practice return 0; }