0

Here's the code I'm trying to change

string binary = "000000100001000100010000000100000"
bitset<32> set(binary);
cout << hex << set.to_ulong() << endl;

The code shows 2112010 but I want it to show 02112010.

David G
  • 90,891
  • 40
  • 158
  • 247

2 Answers2

2
std::cout << std::setfill('0') << std::setw(5) << i << std::endl;
NPE
  • 464,258
  • 100
  • 912
  • 987
0

that is the same number you can format it with the 0 by using format specifiers if you need to retain the zero you need to store it as a string,

rerun
  • 24,358
  • 6
  • 47
  • 75