#include #include #include #include "CPstring.h" // file: stats3.cc; author: D. Ramm; date: 10/15/96 // file input; while with EOF to exit // initialization from limits.h // move count to function with reference parameter // stats and other things void Count(int & tally) { tally++; } int main() { int number, count = 0; int sum = 0, max = INT_MIN, min = INT_MAX; string filename; ifstream filein; cout << "Enter file name: "; cin >> filename; filein.open(filename); while (filein >> number) { Count(count); cout << "Do something with number: " << number << endl; } if (count == 0) cout << "No data found in file " << filename << endl; else cout << count << " numbers were read." << endl; return 0; } Sample output: stats3 Enter file name: data Do something with number: 1 Do something with number: 2 Do something with number: 4 Do something with number: 7 Do something with number: -2 Do something with number: 33 Do something with number: -11 Do something with number: 12 8 numbers were read.