Skip to content

Instantly share code, notes, and snippets.

@cuiwm
Created June 7, 2017 07:35
Show Gist options
  • Save cuiwm/fcd56b1c1f036723921963f7e62c06dd to your computer and use it in GitHub Desktop.
Save cuiwm/fcd56b1c1f036723921963f7e62c06dd to your computer and use it in GitHub Desktop.
print string with iostream cout
void print(std::string const& buf) {
| 63 for (std::string::const_iterator it = buf.begin(), end = buf.end();
| 64 it != end;
- 65 ++it) {
2 66 std::cout
2 67 << std::setw(2)
2 68 << std::hex
2 69 << std::setfill('0')
2 70 << (static_cast<int>(*it) & 0xff)
2 71 << ' ';
2 72 }
| 73 std::cout << std::dec << std::endl;
| 74 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment