fork download
  1. #include <iostream>
  2. #include <bitset>
  3. #include <sstream>
  4.  
  5. const char input[] =
  6. "000000000000000100000010000000110000010000000101000001100000011100001000"
  7. "000010010000101000001011000011000000110100001110000011110001000000010001"
  8. "000100100001001100010100000101010001011000010111000110000001100100011010"
  9. "000110110001110000011101000111100001111100100000001000010010001000100011"
  10. "001001000010010100100110001001110010100000101001001010100010101100101100"
  11. "001011010010111000101111001100000011000100110010001100110011010000110101"
  12. "001101100011011100111000001110010011101000111011001111000011110100111110"
  13. "001111110101010101010101010101010101010101010101010101010101010101010101";
  14.  
  15. std::string bintxt_2_hextxt(const std::string &bin)
  16. {
  17. std::stringstream reader(bin);
  18. std::stringstream result;
  19.  
  20. while (reader)
  21. {
  22. std::bitset<8> digit;
  23. reader >> digit;
  24. result << std::hex << digit.to_ulong();
  25. }
  26.  
  27. return result.str();
  28. }
  29.  
  30. int main()
  31. {
  32. std::cout << bintxt_2_hextxt(input) << '\n';
  33. return 0;
  34. }
Success #stdin #stdout 0s 3236KB
stdin
Standard input is empty
stdout
0123456789abcdef101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f55555555555555550