title: C access enum from struct
body: <p>My problem is that <code>car_name_str</code> could not be resolved. Why is it not callable and I want to keep the code structure?</p>
  <p>I want to keep the structure as struct with union and enum (different datatypes).</p>
  <p>Template: <a href="https://stackoverflow.com/questions/18577404/how-can-mixed-data-types-int-float-char-etc-be-stored-in-an-array">How can mixed data types (int, float, char, etc) be stored in an array?</a></p>
  <pre><code>//car_union.h
      typedef struct {
          enum { number_of_seats_int, car_cost_float, car_name_str } type;    
          union {
              int number_of_seats;
              float car_cost;
              char* car_name;
              } value;
      }Car_data_ex[30][3];   
  
      extern Car_data_ex *Car_data[30][3];
  
  //fill_car.c
  #include &quot;car_union.h&quot;
  Car_data_ex *Car_data[30][3];
  Car_data[0][0]-&gt;type = car_name_str;  //-&gt; because pointer but doesnt work
  Car_data[0][0]-&gt;value-&gt;car_name= &quot;land rover&quot;;
  
  Car_data[0][1]-&gt;type = car_cost_float;    //doesnt work
  Car_data[0][1]-&gt;value-&gt;car_cost= 45000;
  </code></pre>