I'm working on a programming assignment and I am using the bitset<> function in C++ to print put the binary representation of an integer by 16 bits. I am having a hard time trying to print the 16 bits into four groups of four bits with a space in between. How can I do that with a bitset function?
cout << "0b" << bitset<16>(integer) << "\t";
This prints out if the integer was 1
0b0000000000000001
What i am trying to print out is
0b0000 0000 0000 0001
You could implement a filtering stream, but why not keep it simple?