title: Access three dimensional array via pointer
body: <p>How do I access a three-dimensional array via pointers? At the moment I have this code, trying to get the same results. I need the access via pointers to use the values in the array in OpenCL.</p>
  
  <pre><code>for (l = 0; l &lt; NumberOfLayers - 1; l++) {
    for (i = 0; i &lt; NeuronsPerLayer[l]; i++) {
      for (j = 0; j &lt; NeuronsPerLayer[l + 1] - bias[l + 1]; j++) {
        cout&lt;&lt;Synweights[l][i][j]&lt;&lt;endl;  
        cout&lt;&lt;*(*Synweights[0]+l*NumberOfLayers + i * NeuronsPerLayer[l] + j)&lt;&lt;endl;
      }
    }
  }
  </code></pre>
  
  <p><code>Synweights</code> is declared as:</p>
  
  <pre><code>double ***Synweights
  Synweights = (double ** *)malloc((NumberOfLayers - 1) * sizeof(double **));
  for (l = 0; l &lt; NumberOfLayers - 1; l++) {
      Synweights[l] = (double **)malloc(NeuronsPerLayer[l] * sizeof(double *));
      for (i = 0; i &lt; NeuronsPerLayer[l]; i++) {
          Synweights[l][i] = (double *)malloc((NeuronsPerLayer[l + 1] - bias[l + 1]) * sizeof(double));
      }
  }
  </code></pre>