fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct element_1 {
  5. int x;
  6. char y;
  7. };
  8.  
  9. struct element_2 {
  10. char y;
  11. int x;
  12. };
  13.  
  14. int main()
  15. {
  16. struct element_1 *a;
  17. a = (struct element_1 *)malloc(sizeof(struct element_1));
  18. a->x = 48;
  19. a->y = 'A';
  20. struct element_2 *b = (struct element_2 *)a;
  21. printf("%d\n", b->x);
  22. printf("%c\n", b->y);
  23. return 0;
  24. }
Success #stdin #stdout 0s 2380KB
stdin
Standard input is empty
stdout
65
0