Read 2D array from file in C
<p>I know this has been both answered and asked before, but I can't quite understand the answers given in those posts, so I feel like I have no option but to ask it myself. It's definitely a beginner's question so please bear with me and don't get overly complicated unless it's absolutely needed.</p>

<p>What I want to do is to read a 2x3 matrix from a .txt file, such as</p>

<pre><code>12 14 15
24 244 988
</code></pre>

<p>and then store it in a 2D array, let's call it "array", so that array[0][0] would = 12, and array[1][1] = 244 etc..</p>

<p>What I've come up with so far is simply this: </p>

<pre><code>for (int a = 0; a &lt; 2; a++) {
        for (int b = 0; b &lt; 3; b++) {
                fscanf_s(stream, "%d", array[a][b]);
        }

}
</code></pre>

<p>It compiles, but then crashes, so I'm not sure what's wrong exactly. It both compiles and runs perfectly if I remove that fscan_s statement so the problem has to be there. </p>

<p>Any help would be greatly appreciated. Thanks!</p>