fork download
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. unsigned char ip[4] = { 192, 168, 0, 1 };
  9. for(int i = 0; i < 4; ++i)
  10. cout << bitset<8>(ip[i]) << " ";
  11. cout << endl;
  12. }
  13.  
Success #stdin #stdout 0s 4956KB
stdin
Standard input is empty
stdout
11000000 10101000 00000000 00000001