I have the following:
char const* code = "3D";
I need to convert this 2-digit lexical hex into a std::string, which will be a string with length of 1 (not including null terminator). I have the boost library at my disposal as well. How can I do this?
In the example above, I should have a std::string that prints "=" if properly converted.
I think something on this order should work:
std::istringstream buffer("3D");
int x;
buffer >> std::hex >> x;
std::string result(1, (char)x);
std::cout << result; // should print "="
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With