C++ Program help: Structs, arrays, loops, input files, loop not working?
<p>I am trying to write a program which will declare an array of 5 structs from information read from a file. Then I use a loop to the print the information of every element in the array.</p>

<p>The code I have written only seems to read one line from the txt. file. Any tips or advice would be appreciated. </p>

<pre><code>#include &lt;istream&gt;
#include &lt;iostream&gt;
#include &lt;ostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;
using namespace std;


int main ()
{
    struct Bankinfo{
        string name;
        int accountnum;
        float checking;
        float savings;
        string phone;
    } bankinfo[5];


    int i;
    i=0;
    cout&lt;&lt;"This is a test program"&lt;&lt;endl;
    char x;
    x=0;
    for (i=0;i&lt;=6;i++)
    {
        ifstream infile;
        char testinfo [10001];
        infile.open("testinfo.txt");
        cin.get(testinfo,10001);
        cout&lt;&lt;testinfo&lt;&lt;endl;

        infile&gt;&gt;bankinfo [i].name&gt;&gt;bankinfo [i].accountnum&gt;&gt;bankinfo [i].checking&gt;&gt;bankinfo [i].savings&gt;&gt;bankinfo [i].phone;


        cout&lt;&lt;setw(10) &lt;&lt; (bankinfo[i].name);
        cout&lt;&lt;setw(10) &lt;&lt;(bankinfo [i].accountnum);
        cout&lt;&lt;setw(10) &lt;&lt;(bankinfo [i].checking);
        cout&lt;&lt;setw(10) &lt;&lt;setprecision (2)&lt;&lt;fixed&lt;&lt;(bankinfo [i].savings);
        cout&lt;&lt;setw(15) &lt;&lt;(bankinfo [i].phone);

    }
    cout&lt;&lt;"                                             "&lt;&lt;endl;
    cout&lt;&lt;"Thanks for using the program"&lt;&lt;endl;
    return (0);
}
</code></pre>
