title: c++ read numbers from text into integer array, calculate average
body: <p>I'm struggling with a class assignment. I've tried writing this several ways, I'm extremely confused.</p>
  
  <p>Assignment: </p>
  
  <blockquote>
    <p>Read in ten integer values from a from a file, and store them in an
    array or vector. The program you will write will read and store the
    last ten values read from a temperature gauge. The reading of the
    values should be done in a separate function that takes an integer
    array as a parameter, and read from a file named tempInput.txt: 
    example: void readData(int tempArray[]) The file numbers will be on
    consecutive lines.  Then, from main, you will call another function,
    whose signature and return type is thus:  bool isDangerous(int
    tempArray[]);  The function is dangerous will sum the values in the
    tempArray and divide by 10 storing the result (average) in another
    variable of the appropriate data type.  Then, if the temperature is
    greater than 100, the function should return true. if it is 100 or
    less, it should return false.  in main, you should use the function in
    a way such that you print: the temp is ok (if return false) or, the
    temp is too hot (if > 100)</p>
  </blockquote>
  
  <p>If I write a function readData(int array[]) then I must already an array to pass as the argument. 
  But, the entire purpose of this function is to read from file, THEN create the array. Do I need to write a placeholder temp. array? </p>
  
  <p>Do I need to make the array a string then parse to int or double? </p>
  
  <p>My non-working start is: </p>
  
  <pre><code> #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  //prototypes
  void readTemp();
  
  
  int main()
  {
      int allTemp[10];
  
      readTemp();
  }
  
  void ReadTemp()
  {
      ifstream in_File;
      int inNumbers[10];
      double average;
  
      in_File.open("tempInput.txt");
  
      for(int i = 0; i &lt; 10; ++i)
      {
          in_File&gt;&gt;inNumbers[i];
          average = inNumbers[i++]/i;
      }
      cout&lt;&lt; average &lt;&lt;endl;
  }
  </code></pre>
  
  <p>Thanks for any tips. I couldn't get the file read in working so I haven't started on the function that will average the data and return bool. </p>