input from txt file to arrays
<p>I have a text file with a line like:</p>

<pre><code>James Dean         10 Automotive      27010.43
</code></pre>

<p>and I need to read that file and put each of the 4 above into arrays.</p>

<pre><code>char nameArray[MAX][NAME_MAX];
int yearArray[MAX];
char departmentArray[MAX][DEP_MAX];
double payArray[MAX];


while(i &lt; MAX &amp;&amp; infile) {

     infile.getline(nameArray[i], 20);
     infile &gt;&gt; yearArray[i];
     infile.getline(departmentArray[i], 15);
     infile &gt;&gt; payArray[i];

     cout &lt;&lt; nameArray[i] &lt;&lt; "  " &lt;&lt; yearArray[i] &lt;&lt; "  " &lt;&lt; departmentArray[i] &lt;&lt; "  " &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; payArray[i] &lt;&lt; endl;
     i++;
    }
</code></pre>

<p>The code is cut down just to give you an idea of what I am trying to do, but when I run this, I get something like: </p>

<pre><code>James Dean         -858993460    -92559631349317830000000000000000000000000000
000000000000000000.00
</code></pre>

<p>Thanks for the help.</p>

<p>==== Edit ==========================================</p>

<p>I changed from getline to get, thanks for that.  I have to use get and not >> because some of the lines I am reading in are more than just "James Dean", they are up to 20 char long...ex: "William K. Woodward" is another one.  </p>

<p>So, if I just use get, then it reads the first line in fine, but then I get the same messed up text for the second line.</p>

<p>Here is the code:</p>

<pre><code> infile.get(nameArray[i], 20);
 infile &gt;&gt; yearArray[i];
 infile.get(departmentArray[i], 15);
 infile &gt;&gt; payArray[i];
</code></pre>
