Created
June 7, 2017 07:35
-
-
Save cuiwm/fcd56b1c1f036723921963f7e62c06dd to your computer and use it in GitHub Desktop.
print string with iostream cout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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