title: Problems accessing pre-defined array of floats in C++
body: <p>I'm trying to make use of precalculated values by outputting them to a header file and then compiling them for use.</p>
  
  <p>The precalculated values are cube co ordinates mapped onto a sphere and the data structure takes the form of:</p>
  
  <pre><code>typedef float heightMapCubeFace[5][5][3];
  </code></pre>
  
  <p>I am defining each face seperately like so:</p>
  
  <pre><code>    heightMapCubeFace face1 = {{{ -2.88675, -2.88675, -2.88675 }, { -3.38502, -3.38502, -1.44338 }, { -3.53553, -3.53553, 0 }, { -3.38502, -3.38502, 1.44338 }, { -2.88675, -2.88675, 2.88675}}, 
  {{ -1.44338, -3.38502, -3.38502 }, { -1.69251, -4.38986, -1.69251 }, { -1.76777, -4.67707, 0 }, { -1.69251, -4.38986, 1.69251 }, { -1.44338, -3.38502, 3.38502}}, 
  {{ 0, -3.53553, -3.53553 }, { 0, -4.67707, -1.76777 }, { 0, -5, 0 }, { 0, -4.67707, 1.76777 }, { 0, -3.53553, 3.53553}}, 
  {{ 1.44338, -3.38502, -3.38502 }, { 1.69251, -4.38986, -1.69251 }, { 1.76777, -4.67707, 0 }, { 1.69251, -4.38986, 1.69251 }, { 1.44338, -3.38502, 3.38502}}, 
  {{ 2.88675, -2.88675, -2.88675 }, { 3.38502, -3.38502, -1.44338 }, { 3.53553, -3.53553, 0 }, { 3.38502, -3.38502, 1.44338 }, { 2.88675, -2.88675, 2.88675}} 
  }; 
  </code></pre>
  
  <p>and finally:</p>
  
  <pre><code>heightMapCubeFace * heightMapSaved[6] = {&amp;face1, &amp;face2, &amp;face3, &amp;face4, &amp;face5, &amp;face6};
  </code></pre>
  
  <p>Eventually the data structue will be bigger I hav ejust set it to 5x5 to make things easier at first.</p>
  
  <p>The problem I am having is when I want to get the values back, something weird is happening and as a result access violations are occuring.</p>
  
  <p>As shown in the following <a href="http://i.stack.imgur.com/wVT4s.png" rel="nofollow">image</a></p>
  
  <p>As you can see the assigned value does not match that of the data structure.  Instead the value for index <code>[0][0][0][1]</code> is given the value of index <code>[0][0][1][0]</code>.
  <a href="http://i.stack.imgur.com/IP29K.png" rel="nofollow">here</a></p>
  
  <p>I picked up on this because an unhaddled exception is thrown at a later stage (access violation), I think it is because of this index problem but can't be certain.</p>
  
  <p>I don't understand what is going on, am I dereferencing the pointer wrong?</p>
  
  <p>Any help would be much appriciated, thanks.</p>
  
  <p>Here is the code for that section:</p>
  
  <pre><code>    for(int i = 0; i &lt; 6; i++)
      {    
          for(int j = 0; j &lt; heightMapRes; j++)
          {
              for(int k = 0; k &lt; heightMapRes; k++)
              {
                  float xCoord =  *(heightMapSaved[i][j][k][0]);
                  float yCoord =  *(heightMapSaved[i][j][k][1]);
                  float zCoord =  *(heightMapSaved[i][j][k][2]);
  
                  float newValue = myModule.GetValue( xCoord, yCoord, zCoord);
  
                  heightMap.SetValue( j, k, newValue);
              }
          }
      }
  </code></pre>