fork download
  1. #include <stdio.h>
  2.  
  3. // Source - https://stackoverflow.com/a/26361366
  4. // Posted by Emily L.
  5. // Retrieved 2026-02-04, License - CC BY-SA 3.0
  6.  
  7. typedef union {
  8. struct{
  9. double x;
  10. double y;
  11. double z;
  12. };
  13. double raw[3];
  14. } vec3d_t;
  15.  
  16. int main()
  17. {
  18. vec3d_t v;
  19. v.x = 4.0;
  20. v.raw[1] = 3.0; // Equivalent to v.y = 3.0
  21. v.z = 2.0;
  22. printf("%lf %lf %lf\n", v.x, v.y, v.z);
  23. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
4.000000 3.000000 2.000000