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
  • 94,763
  • 41
  • 167
  • 253

2 Answers2

2
std::cout << std::setfill('0') << std::setw(5) << i << std::endl;
NPE
  • 486,780
  • 108
  • 951
  • 1,012
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
  • 25,014
  • 6
  • 48
  • 78