Assign pointer-to-pointer in for loop C++
<p>I'm trying to store a 2-d array in a pointer-to-pointer iteratively. I'm filling it with random Gaussian values, but that's not the important part. I try to fill the array pointed to by <code>A</code> but get a "bad access code" error. How would I correctly fill the array/pointer? Thanks. </p>

<p>int main() {</p>

<pre><code>int N = 100;
double **A[N][N];
for(int i = 0; i&lt; N; i++){
    for(int j =0; j &lt; N; j++){
        random_device rd;
        default_random_engine generator;
        generator.seed( rd() );
        normal_distribution&lt;double&gt; distribution(0.0,1.0);
        **A[i][j] = distribution(generator); // error here, bad access code 1
    }
}
</code></pre>