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