fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct elem {
  4. void * d;
  5. } Elem;
  6.  
  7. int main() {
  8. Elem *p = &(struct elem) { .d = NULL }; //malloc(sizeof(Elem));
  9. Elem e;
  10. double pi = 3.14;
  11. e.d = &pi;
  12. p->d = &pi;
  13. printf("%f\n", *((double *)p->d));
  14. printf("%f\n", *((double *)e.d));
  15. }
  16.  
  17. //https://pt.stackoverflow.com/q/110588/101
Success #stdin #stdout 0s 4200KB
stdin
Standard input is empty
stdout
3.140000
3.140000