fork download
  1. #include <new>
  2.  
  3. int main()
  4. {
  5. short buf[sizeof(double)];
  6. double d;
  7.  
  8. buf[0] = 2; // accessed as short
  9.  
  10. *(double*)buf = 345.465;
  11. d = *(double*)buf;
  12.  
  13. double* d1 = reinterpret_cast<double*>(buf);
  14. *d1 = 32.234;
  15. d = *d1;
  16.  
  17. double* d2 = new (buf) double;
  18. *d2 = 42.0323;
  19. d = *d2;
  20. }
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty