fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct base
  5. {
  6. double some;
  7. };
  8.  
  9. struct derived
  10. {
  11. double some;
  12. int value;
  13. };
  14.  
  15. int main(void) {
  16. struct base *b = malloc(sizeof(struct derived));
  17. b->some = 123.456;
  18. struct derived *d = (struct derived*)(b);
  19. d->value = 4;
  20. struct base *bb = (struct base*)(d);
  21. printf("%f\t%f\t%d\n", d->some, bb->some, d->value);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 10304KB
stdin
Standard input is empty
stdout
123.456000	123.456000	4