/*****************************************************************************/ /*****************************************************************************/ /*This program reads in a number triplets, X Y Z and then prints the triplets to the screen and to a file */ /*****************************************************************************/ /*****************************************************************************/ #include //Normal Input/Output #include //File Input/Output using namespace std; int main() { //FILE variables ifstream inputfile; ofstream outputfile; char outputfilename[80] = "output1.txt"; //other variables double x, y, z; //OPEN the input file inputfile.open("input1.txt"); //OPEN the output file outputfile.open(outputfilename); //READ input from file, PRINT to screen & PRINT to another file //////////////////////////////////////////////////// //This method is a very simple approach & the most //efficient. It will read in triples of numbers until //there are less than 3 left, then it will terminate //////////////////////////////////////////////////// while (inputfile >> x >> y >> z) { cout << x << " " << y << " " << z << endl; outputfile << x << " " << y << " " << z << endl; } //CLOSE the input file inputfile.close(); //CLOSE the output file outputfile.close(); return 0; }