// readInt.cc P. Conrad 02.08.06  for CISC181
// read an input file of integers and print the sum
// WARNING.. this program has a bug in it!

#include <iostream> // we are doing normal keyboard i/o 
#include <fstream>
using namespace std; // we'll talk about this later


int main(void)
{
  int sum;
  int x;

  ifstream infile("nums.dat",ios::in);

  if (!infile)
    {
      cerr << "Sorry, I could not open infile.dat" << endl;
      return 1;
    }

  infile >> x;
  while (!infile.eof())
    {
      
      sum = sum + x;
      infile >> x;
    }


  cout << "The sum is " << sum << endl;
  return 0;
}

