title: stack with objects of different type in c
body: <p>I want to design a stack that can contain objects of different type(int, float, double, or char). The type of the stack is decided depending upon the declaration. This can be easily achieved using c++, with the help of templates. I am wondering how it can be done in c, where there is no templates....?
  This is the basic definitions i have made:</p>
  
  <pre><code>#define STACKSIZE 100
  #define INT 1
  #define FLOAT 2
  #define CHAR 3
  
  struct stackelement{
      int etype;
      union {
        int ival;
        float fval;
        char cval;  
      } element;
  };
  struct stack{
      int top;
      struct stackelement items[STACKSIZE];
  };
  </code></pre>
  
  <p>Using this definitions how can I declare a stack with a specific type, and how the push and pop operations will be implemented?</p>