fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, const char * argv[])
  10. {
  11. {
  12. string s = "Hello, \0\0\0world"s;
  13. for(auto it = s.begin(); it != s.end(); ++it) cout << "code: " << hex << int(*it) <<endl;
  14. }
  15. cout << "---------------\n";
  16. {
  17. string s = "Hello, \0\0\0world";
  18. for(auto it = s.begin(); it != s.end(); ++it) cout << "code: " << hex << int(*it) <<endl;
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 4400KB
stdin
Standard input is empty
stdout
code: 48
code: 65
code: 6c
code: 6c
code: 6f
code: 2c
code: 20
code: 0
code: 0
code: 0
code: 77
code: 6f
code: 72
code: 6c
code: 64
---------------
code: 48
code: 65
code: 6c
code: 6c
code: 6f
code: 2c
code: 20