title: How to store a double in a void * in C
body: <p>I found <a href="https://stackoverflow.com/questions/6575340/">Converting double to void* in C</a> but i cant get none of the solutions to run. I want to create a struct with a void pointer to store different types of data.</p>
  
  <pre><code>struct Table {
      int id;
      void *val;
  }; 
  </code></pre>
  
  <p>In the main function i assign the values like</p>
  
  <pre><code>struct Table t;
  
  int i = 1;
  double d = 2.5;
  
  double *pd = &amp;d;
  void **p = (void**)pd;
  void *dp = *p;
  
  t.id = i;
  t.val = dp;
  </code></pre>
  
  <p>but i cant get the value of the double..</p>
  
  <pre><code>printf("%d %f", t.id, t.val);
  </code></pre>
  
  <p>Thank you.</p>