C++ reading numbers from a text file into an array
<p>Hello i am student of the first year thats why i got problem with such easy task.
I am working currently on matrix calculator but in the very begging i occured some problems with reading numbers from a text file and printing them on screen
Here is my code:</p>

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

using namespace std;
 int main()
{
    ifstream infile;
    infile.open("matrix.txt", ios::in);
    //check for an error
    if(infile.fail())
    {
        cerr&lt;&lt;"Error opening file";
        exit(0);
    }
    //char sign;
    int n = 0;
    double matrix[n];
    while(!infile.fail())
    {
        infile &gt;&gt; matrix[n];
        n++;
        //if(infile.eof()) {break;}
    }

infile.close();


    for(int i = 0;i&lt;9;i++)
    {
        cout &lt;&lt; matrix[i]&lt;&lt;endl;
    }
return 0;
}
</code></pre>

<p>In the shortcut about the whole program it is supposed to read from a text file and calculate a determinant of 2x2 matrix or 3x3 matrix. If you can give me any ideas which will be useful in the future for example how i can check if the line in text file ended i would be thankful. But mostly i want to know what i am doing wrong. Thank's from above.</p>