Reading in from file to 2 arrays
<p>Here is my problem, I'm trying to read in data from a file <code>"beginningbalance.dat"</code>, containing the following:</p>

<pre><code>111
100.00
200.00
50.00
222
200.00
300.00
100.00
</code></pre>

<p>What I want to do is read in <code>111</code> for <code>customer_number[0]</code> and <code>222</code> for <code>customer_number[1]</code>. For <code>new_balance[0]</code>, I want to add the values of the 3 numbers under <code>111</code> and <code>new_balance[1]</code> the numbers under <code>222</code>.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;



int main()
{
  int count = 0;
  double val1, val2, val3, sum;
  int customer_number[2];//Array for holding customer number from file.
  double new_balance[2];//Array for holding added values from file.

  ifstream beginning_balance;
  beginning_balance.open("beginningbalance.dat");



  while(beginning_balance)
    {
        beginning_balance &gt;&gt; customer_number[count];
        beginning_balance &gt;&gt; val1;
        beginning_balance &gt;&gt; val2;
        beginning_balance &gt;&gt; val3;

        sum = val1+val2+val3;

        new_balance[count] = sum; //Supposed to read in customer id number then 3 values from files, then starts itself over and reads a new customer number for the new array element.
        count++;                   //
    }

  cout&lt;&lt;val1&lt;&lt;" "&lt;&lt;val2&lt;&lt;" "&lt;&lt;val3&lt;&lt;"\n\n";//Testing values being read in

  cout&lt;&lt;"Customer Number #"&lt;&lt;customer_number[0]&lt;&lt;endl;//Should read Customer Number # 111
  cout&lt;&lt;"New Balance $"&lt;&lt;new_balance[0]&lt;&lt;endl;
  cout&lt;&lt;"Customer Number #"&lt;&lt;customer_number[1]&lt;&lt;endl;//Should read Customer Number # 222
  cout&lt;&lt;"New Balance $"&lt;&lt;new_balance[1]&lt;&lt;endl;



  system("pause");
  return 0;
}
</code></pre>

<p>My output is</p>

<pre><code>100  -858993460 -858993460

Customer Number #111
New Balance $-1.71799e+009
Customer Number #0
New Balance $5.48413e-322
Press any key to continue...
</code></pre>

<p>{I had my <code>val1,val2,val3</code>,and <code>sum</code> set to <code>int</code> when it should have been something to allow floating point numbers, I also only allowed 1 element for each array.}</p>
