fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string aBinaryIPAddress = "0101100111101101";
  7. size_t len = aBinaryIPAddress.size();
  8. for (int i = 0 ; i != 4 ; i++) {
  9. cout << "Digit " << i << ": " << aBinaryIPAddress.substr(len-4*(i+1), 4) << endl;
  10. }
  11. return 0;
  12. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Digit 0: 1101
Digit 1: 1110
Digit 2: 1001
Digit 3: 0101