loading into 2d array from file in c++
<p>I am having trouble reading numbers from a file into a 2d array in c++.  It reads the first row just fine but the rest of the rows are populated with 0's.  I have no idea what I'm doing wrong. </p>

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

using namespace std;

int main()
{
    int myarray[20][20];

    int totRow = 20, totCol = 20, number, product, topProduct = 0, row, col, count;
    char element[4];

    ifstream file;

    file.open( "c:\\2020.txt" );

    if( !file )
    {
        cout &lt;&lt; "problem";
        cin.clear();
        cin.ignore(255, '\n');
        cin.get();

        return 0;
    }

    while( file.good())
    {
        for( row = 0; row &lt; totRow; row++ )
        {
            for( col = 0; col &lt; totCol; col++ )
            {
                file.get( element, 4 );
                number = atoi( element );
                myarray[row][col] = number;
                cout &lt;&lt; myarray[row][col] &lt;&lt; " ";
            }
            cout &lt;&lt; endl;

        }
        file.close();
    } 
</code></pre>
