title: Solution for "dereferencing `void *' pointer" warning in struct in C?
body: <p>I was trying to create a pseudo super struct to print array of structs. My basic 
  structures are as follows.</p>
  
  <pre><code>/* Type 10 Count */
  typedef struct _T10CNT
  {
      int _cnt[20];
  } T10CNT;
  
  ...
  
  /* Type 20 Count */
  typedef struct _T20CNT
  {
      long _cnt[20];
  } T20CNT;
  ...
  </code></pre>
  
  <p>I created the below struct to print the array of above mentioned structures. I got dereferencing void pointer error while compiling the below code snippet.</p>
  
  <pre><code>typedef struct _CMNCNT
  {
      long  _cnt[3];
  } CMNCNT;
  
  static int printCommonStatistics(void *cmncntin, int cmncnt_nelem, int cmncnt_elmsize)
  {
      int ii;
      for(ii=0; ii&lt;cmncnt_nelem; ii++)
      {
          CMNCNT *cmncnt = (CMNCNT *)&amp;cmncntin[ii*cmncnt_elmsize];
          fprintf(stout,"STATISTICS_INP: %d\n",cmncnt-&gt;_cnt[0]);
          fprintf(stout,"STATISTICS_OUT: %d\n",cmncnt-&gt;_cnt[1]); 
          fprintf(stout,"STATISTICS_ERR: %d\n",cmncnt-&gt;_cnt[2]);
      }
      return SUCCESS;
  }
  
  T10CNT struct_array[10];
  ...
  printCommonStatistics(struct_array, NELEM(struct_array), sizeof(struct_array[0]);
  ...
  </code></pre>
  
  <p>My intention is to have a common function to print all the arrays. Please let me know the correct way of using it.</p>
  
  <p>Appreciate the help in advance.</p>
  
  <p>Edit: The parameter name is changed to cmncntin from cmncnt. Sorry it was typo error.</p>
  
  <p>Thanks,
  Mathew Liju</p>