fork download
  1. #include <stdio.h>
  2.  
  3. struct xy {
  4. int x;
  5. int y;
  6. };
  7.  
  8. struct zw {
  9. int z;
  10. struct xy w;
  11. };
  12.  
  13. int main(void)
  14. {
  15. struct zw a;
  16. struct zw b = {10, {20, 30}};
  17. struct zw c = {40, {50, 60}};
  18.  
  19. a.z = b.z;
  20. printf("a.z = %d\n", a.z);
  21.  
  22. a.w.x = b.w.x;
  23. printf("a.w.x = %d\n", a.w.x);
  24.  
  25. a.w = b.w;
  26. printf("a.w.y = %d\n", a.w.y);
  27.  
  28. a = c;
  29. printf("a.z = %d\n", a.z);
  30. printf("a.w.x = %d\n", a.w.x);
  31. printf("a.w.y = %d\n", a.w.y);
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
a.z = 10
a.w.x = 20
a.w.y = 30
a.z = 40
a.w.x = 50
a.w.y = 60