title: Storing and Accessing a 2D Array in a Struct
body: <p>I am trying to code a program in C that generates a spiral based on user input and prints it to the console. I cannot figure out how to access the 2D array "data" that I defined in the struct "Spiral". How do I fix the "warning: assignment from incompatible pointer type" error?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  typedef struct Spiral {
      int size;
      int **data;
  } Spiral;
  
  Spiral generateSpiral(int size);
  void printSpiral(Spiral spiral);
  static int rotate();
  
  int main() {
      int size;
      scanf("%d", &amp;size);
      Spiral spiral = generateSpiral(size);
      printSpiral(spiral);
      return 0;
  }
  
  Spiral generateSpiral(int size) {
      int data[size][size];
      int i;
      for (i = 0; i &lt; size; i++) {
          int j;
          for (j = 0; j &lt; size; j++) {
              data[i][j] = 0;
          }
      }
  
      for (i = 0; i &lt; size; i++) {
          data[0][i] = 1;
      }
  
      int currX = 0;
      int currY = size - 1;
  
      for (i = size - 1; i &gt; 0; i -= 2) {
          int j;
          for (j = 0; j &lt; 2; j++) {
              int k;
              switch (rotate()) {
                  case 0:
                      for (k = 0; k &lt; i; k++) {
                          data[++currX][currY] = 1;
                      }
                      break;
                  case 1:
                      for (k = i; k &gt; 0; k--) {
                          data[currX][--currY] = 1;
                      }
                      break;
                  case 2:
                      for (k = i; k &gt; 0; k--) {
                          data[--currX][currY] = 1;
                      }
                      break;
                  case 3:
                      for (k = 0; k &lt; i; k++) {
                          data[currX][++currY] = 1;
                      }
                      break;
              }
          }
      }
      Spiral spiral;
      spiral.size = size;
      spiral.data = data;
      return spiral;
  }
  
  void printSpiral(Spiral spiral) {
      int i;
      for (i = 0; i &lt; spiral.size; i++) {
          int j;
          for (j = 0; j &lt; spiral.size; j++) {
              switch (spiral.data[i][j]) {
                  case 0:
                      printf(" ");
                      break;
                  case 1:
                      printf("#");
                      break;
              }
          }
          printf("\n");
      }
  }
  
  static int rotate() {
      static int val = 0;
      int tmp = val;
      val++;
      if (val &gt; 3)
          val = 0;
      return tmp;
  }
  </code></pre>