title: How do I return an array of struct from a function?
body: <p>How do I return an array of struct from a function? 
  Here's my work; it's pretty simple to understand. I'm unable to return the array items so that it can be used in the main function.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  struct Operador
  {
  
      char name[32];
      char telefone[15];
      char age[3];
  };
  
  struct Operator fun();
  struct Operator fun()
  {
      struct Operador items[3];
      int n;
      for(n=0;n&gt;2;n++){
          printf(" name: "); gets(items[n].nome);
          printf(" telefone: "); gets(items[n].telefone);
          printf(" age: "); gets(items[n].idade);
      }
      return items[n];
  }
  
  int main()           
  {
      int j;
      items = fun();
  
      printf("\n\n");
      for(j=0;j&gt;2;j++){
          printf(items[j].name);
          printf(items[j].telefone);
          printf(items[j].age);
          printf("\n\n");
      }
  }
  </code></pre>