#include<iostream.h>
#include<fstream.h>

// burton rosenberg
// March 15, 1997
// example of reading integers from a file,
// for Assignment 7, Math 120.

/* The file format is
num_of_integers
int_1
int_2
...
int_n

   For example:

4
-9
3
2
17

*/

void main() {
   ifstream inFile ;

   inFile.open(  "myFile.txt") ;
   if ( !inFile ) {
      cout << "Could not open file myFile.txt\n" ;
      return ;
   }

   const int MAXSIZE = 20000 ;
   int a[MAXSIZE] ;
   int i, aSize ;
   
   inFile >> aSize ;
   if ( aSize > MAXSIZE ) {
      cout << "Too many integers. " << MAXSIZE << " is the maximum.\n" ;
      return ;
   }

   for ( i=0; i<aSize; i++ ) {
      inFile >> a[i] ;
   }

   cout << aSize << " integers" << endl ; 
   for ( i=0; i<aSize; i++ ) {
      cout << a[i] << endl ;
   }

   inFile.close() ;
}

