Reading from file in c++
<p>Im trying to learn a bit about c++ and have run in to some trouble.</p>

<p>I have the following code:</p>

<pre><code>char board[5][5];
ifstream myReadFile;
myReadFile.open("c:/test.txt");

for(int i=0; i&lt;5; i++)    
{
    for(int j=0; j&lt;5; j++) 
    {
        while (myReadFile.good())     
        {
            board[i][j] = myReadFile.get();                 
            cout &lt;&lt; board[i][j];
        }
    }
}
myReadFile.close();

for(int x=0; x&lt;5; x++)
{
    for(int y=0; y&lt;5; y++)
    {

        cout &lt;&lt; board[x][y];
    }
    cout &lt;&lt; endl;
}
</code></pre>

<p>Now i was expecting the first loop to read the chars from the txt file and this works, so yeah!
But the second loop, i was expecting to print the same char back to cout. However this was not the case, so i add the line</p>

<pre><code>cout &lt;&lt; board[i][j]
</code></pre>

<p>to the first loop to see if they where loading correctly.
This is the result i get</p>

<p><img src="http://tbmilena.dk/test.png" alt="results"></p>

<p>Can someone explain why the second loop isn't printing the same as the first.</p>
