// arraylab.cpp  Example for cps171  Oct 96  J.Remen  - main program only
// Updated for Visual C++ Fall 00
// Reads numbers into an array until a sentinel of 0 is reached and counts
// how many are in the array (excluding the sentinel).
// Program attempts to deal with datafiles with different numbers of
// good data values before the sentinel, and leaves the input marker
// positioned to read the value after the sentinel in the file.
using namespace std;
							  // Max number of good data values allowed
const int MAX_SIZE = 6;
							 // Function prototype
void GetData (ifstream& infile,  int nums[], int& count);

int main()
							 // Array declared big enough to hold all the data
							 // but not the sentinel
{  int nums[MAX_SIZE], count, next;
							 // Open datafile
	ifstream infile;
	if (!infile) {
         cout << "Trouble opening data file\n" ;
		 return 1;
							 // Call function to get the data into the array
							 // and return the count
	GetData (infile, nums, count);
	cout << "Back in main, count is " << count << endl;
							 // Illustrate that the input file marker is at the
							 // correct position
	infile >> next;
	cout << "The next number in the datafile after the sentinel is "
		  << next << endl;
	return 0;
							 // Function definition goes here