// File name: infile.cpp // Author: Xiannong Meng // Date: February 16, 1997 // Course: CS2330 // Assignment: demonstration // Problem statement: This program reads from a input file // and echos to the screen #include #include // needed for any file operation void main(void) { ifstream inFile("infile.cpp"); char ch; int n1, n2; // read a character from input file and copy it to screen while (inFile.get(ch)) cout << ch; // the following loop assumes that a file has // the given format // ch num1 num2 // here is how the test.dat looks like // a 100 200 // b 300 400 ifstream inFtwo("test.dat"); while (inFtwo) { inFtwo >> ch >> n1 >> n2; if (inFtwo) cout << ch << ' ' << n1 << ' ' << n2 << endl; } }