Skip to content

Instantly share code, notes, and snippets.

@lushl9301
Created July 9, 2018 05:12
Show Gist options
  • Save lushl9301/4dce0f8d87dece2df3ceb1355fd1869b to your computer and use it in GitHub Desktop.
Save lushl9301/4dce0f8d87dece2df3ceb1355fd1869b to your computer and use it in GitHub Desktop.
void PrintToHex(const char *memory_space, unsigned long offset) {
const auto *a = reinterpret_cast<const unsigned char *>(&memory_space);
std::cout << std::endl;
for (size_t i = 0; i < offset; ++i) {
std::cout << std::right << std::setw(2) << std::hex << static_cast<unsigned int>(a[i]) << " ";
// std::cout << std::right << std::setw(2) << std::hex << '1' << " ";
// std::cout << memory_space[i] << " ";
if (i % 10 == 0) {
std::cout << std::endl;
}
}
std::cout << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment