title: How to pass two-dimensional array of structures to function?
body: <p>There is a two-dimensional array of structures, I am passing an array pointer to a function:</p>
  
  <pre><code>result.capabilities = (Capabilities **)malloc(sizeof(Capabilities *)*6);
  for(int i=0;i&lt;6;i++){
      result.capabilities[i] = (Capabilities *)malloc(sizeof(Capabilities)*8);
  }
  init_capabilities(&amp;result.capabilities);
  </code></pre>
  
  <p>Function call cause an error:</p>
  
  <blockquote>
    <p>Unhandled exception at 0x003c10f9 in solution.exe: 0xC0000005: Access violation writing location 0xfdfdfdfd.</p>
  </blockquote>
  
  <p>Here is my function:</p>
  
  <pre><code>void init_capabilities(Capabilities ***capabilities) {
      for(int i=0;i&lt;6;i++){
          for(int j=0;j&lt;8;j++){
              printf("%d %d\n",i,j);
              capabilities[i][j]-&gt;room_capabilities = new RoomCapability[rooms_count];
          }
      }
  }
  </code></pre>
  
  <p>I thought that the dimension of the array <code>capabilities</code> - 6x8. It turned out that 1x6.
  An hour headache because of this. Show you how to change the type of argument or how to refer to elements of my array, so that everything fell into place?</p>