title: How to assign pointer to 2D array in struct in C?
body: <p>I am having a problem with assigning a pointer to a 2d array located in a struct in C. The code runs but I am getting a compilation error and can not understand how to get rid of it.</p>
  
  <p>First, the struct</p>
  
  <pre><code>typedef struct{
    double (*cases)[9];
  } myStruct;
  </code></pre>
  
  <p>I then declare a struct of type myStryct and an array in my main program and try to set the pointer in my struct to point at this array:</p>
  
  <pre><code> myStruct a;
   double myArray[5][9] = {
     {0, 1, 2, 3, 4, 5, 6, 7, 8},
     {0, 1, 2, 3, 4, 5, 6, 7, 8},
     {0, 1, 2, 3, 4, 5, 6, 7, 8},
     {0, 1, 2, 3, 4, 5, 6, 7, 8},
     {0, 1, 2, 3, 4, 5, 6, 7, 8},
   }
   a.cases = &amp;myArray;
  </code></pre>
  
  <p>The program run fines and I can access elements via the pointer but I get a compilation error:
   Warning: assignment from compatible pointer type. What is the problem here?</p>