// Bob Myers // numin.cpp // // Example illustrating basic file input #include #include using namespace std; int main() { ifstream fin; fin.open("datafile.txt"); if (!fin) // if the open failed { cerr << "Attempt to open file failed\n"; exit(1); } // read in the file's data, line by line, and print some results // to the screen int x, y, z; int i = 1; while (i <= 10) { fin >> x >> y >> z; // read three values cout << x << " + " << y << " + " << z << " = " << (x + y + z) << '\n'; i++; } cout << "All done!\n"; fin.close(); return 0; }