fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <utility>
  4. using namespace std;
  5.  
  6. void byteswap4(char *p)
  7. {
  8. std::swap(p[0], p[3]);
  9. std::swap(p[1], p[2]);
  10. }
  11.  
  12. float to_float(char *p)
  13. {
  14. return *((float*)p);
  15. }
  16.  
  17. int main() {
  18. char data[] = "\x44\x7C\xCD\x35";
  19. byteswap4(data);
  20. cout << to_float(data) << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1011.21