title: pointer to array of struct in loop with index
body: <p>i have code, but it doesn't compile</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  typedef struct {
      unsigned int ip;
      unsigned int mask;
  } nic_t;
  
  typedef struct {
      int nnic; /*number of nic*/
      nic_t *nic;
  } host_t;
  
  int main(void)
  {
      int i, j;
      host_t *host = malloc(sizeof(host_t) * 5);
      for (i = 0; i &lt; 5; i++) {
          host[i]-&gt;nnic = 3;
          host[i]-&gt;nic = malloc(sizeof(nic_t) * 3);
          for (j = 0; j &lt; host[i]-&gt;nnic; j++) {
              host[i]-&gt;nic[j]-&gt;ip = 0x7f000001;
              host[i]-&gt;nic[j]-&gt;mask = 0xffffff00;
          }
      }
      for (i = 0; i &lt; 5; i++) {
          for (j = 0; j &lt; 3; j++) {
              printf("ip = 0x%x, mask = 0x%x\n",
                      host[i]-&gt;nic[j]-&gt;ip,
                      host[i]-&gt;nic[j]-&gt;mask);
          }
          printf("\n\n");
      }
      return 0;
  }
  </code></pre>
  
  <p>please explain to me how I need to address an array of structures in the program, that there was no compilation errors.
  I have the following errors:</p>
  
  <pre><code>test.c: In function ‘main’:
  test.c:18:10: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  test.c:19:10: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  test.c:21:11: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  test.c:22:11: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  test.c:28:13: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  test.c:29:13: error: invalid type argument of ‘-&gt;’ (have ‘host_t’)
  </code></pre>
  
  <p>thanks for all. it works.</p>