title: How to handle different data types, in one array, in C
body: <p>I would like to simulate the object oriented programming, so in C++, let's consider the following C code:</p>
  
  <pre><code>typedef struct tAnimal{
     char * name;
     int age;
  }tAnimal;
  
  typedef struct tAnimal2{
     char * name;
     int age;
     float size;
  }tAnimal2;   
  </code></pre>
  
  <p>In C++ you can create a table of different objects which are inherited from the same class.
  I would like to do the same in C, let's consider the following code:</p>
  
  <pre><code>tAnimal ** tab;
  tab = malloc(sizeof(tAnimal*)*2);
  tab[0] = malloc(sizeof(tAnimal));
  tab[1] = malloc(sizeof(tAnimal2));
  </code></pre>
  
  <p>Notice that the allocation works because malloc returns a void pointer, and C does not require casting. But I still have no access to the size field, because the type of tab elements is tAnimal after all.</p>
  
  <p>Is there anyway to fix this?, I would like to stay away from void ** pointers.</p>