fstream's getline() works for a little bit...and then breaks
<p>I have a text file with a bunch of numbers separated by newlines, like this:
123.25
95.12 
114.12 etc...</p>

<p>The problem is, when my program reads it, it only copies the number to the array up to the second number and then fills the rest of the elements with zeroes. I've tried using delimiters and ignore statements but nothing has worked.  Here's the code.</p>

<p>Edit(here's the whole program:)</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string.h&gt;
#include &lt;iomanip&gt;
#include &lt;fstream&gt;

using namespace std;


struct utilityInfo
{
    char utility[20];
    double monthlyExpenses[12];
};

int main(){

utilityInfo Utility[3];

char charray[100];

fstream inFile;  
inFile.open("expenses.txt");
inFile.getline(charray, 7);
cout&lt;&lt;charray&lt;&lt;endl;
if(inFile.fail()) cout&lt;&lt;"it didnt work";

for(int i=0; i&lt;12; i++)
{
    inFile.getline(charray,20);
    Utility[0].monthlyExpenses[i]=atof(charray);
}

for(int z=0; z&lt;12; z++)
{
cout&lt;&lt;Utility[0].monthlyExpenses[z]&lt;&lt;endl;
}

inFile.close();


return 0;
} 
</code></pre>

<p>Here's what the text file looks like:</p>

<pre><code>207.14 
177.34
150.55
104.22
86.36
53.97
52.55
58.77
64.66
120.32
153.45
170.90
</code></pre>

<p>And here's what the output looks like:</p>

<pre><code>207.14
177.34
0
0
0
0
0
0
0
0
0
0
</code></pre>
