Advertisement
Guest User

Untitled

a guest
May 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. int main()
  5. {
  6. uint32_t a=21312321;
  7. std::string header;
  8.  
  9. header+=(a>>24);
  10. header+=(a<<8)>>24;
  11. header+=(a<<16)>>24;
  12. header+=(a<<24)>>24;
  13.  
  14. header+=(char) a >> 24;
  15. header+=(char) a >> 16;
  16. header+=(char) a >> 8;
  17. header+=(char) a;
  18.  
  19.  
  20. std::cout<<(uint32_t) (unsigned char) header[0]<<std::endl;
  21. std::cout<<(uint32_t) (unsigned char) header[1]<<std::endl;
  22. std::cout<<(uint32_t) (unsigned char) header[2]<<std::endl;
  23. std::cout<<(uint32_t) (unsigned char) header[3]<<std::endl;
  24.  
  25. uint32_t deser=0;
  26.  
  27. for (size_t i = 0; i != 4; i++)
  28. {
  29. deser += (unsigned char) header[i] << (3-i)*8;
  30. }
  31.  
  32. std::cout<<deser<<std::endl;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement