title: How to access value in array from a pointer that is a member of a struct in C
body: <p>I've searched stackoverflow and seen every combination of the words in my question, but not the question I have.</p>
  
  <p>I have an array of ints, it happens to be a 2d array.</p>
  
  <pre><code>const int themap[something][something] = { {0, ...
  </code></pre>
  
  <p>I have a struct that I want to have a pointer to this array in my program</p>
  
  <pre><code>typedef struct {
  int** mymap;
  } THE_STRUCT
  </code></pre>
  
  <p>In my program I want to iterate over the values of the array through the struct's pointer, but my data seems to be corrupted if i try to access it through the . syntax</p>
  
  <pre><code>int value;
  THE_STRUCT mystruct;
  mystruct = (int**) themap;
  
  ...
  //access the map data from mystruct's pointer?
  value = mystruct.mymap[x][y];
  //doesn't seem to return correct values
  </code></pre>
  
  <p>Taking the struct out of the picture the same exact function works if I directly use the array (as a global variable)</p>
  
  <pre><code>int value;
  ...
  //access the map directly
  value = themap[x][y]
  //everyone is happy!
  </code></pre>
  
  <p>I would like to use the struct as in reality it will carry other information as well as the fact that I will need to be able to assign the pointer to other arrays with different data.</p>