Assume I have a string s that represents a hex value:
string s="0x80";
I want to assign the value of s to v, where v is defined as:
unsigned char v;
What is the simplest way of doing it?
Why do I need it? Because in here, a bloom filter is represented as a vector of unsigned char where each char represents 8 bits. I want to access each char, perform some computation on it, and then store it back in a compatible form. Also, when I print each element of the vector (which is of type unsigned char) it appears in a hex form, e.g. 3a, 98, etc.
v = std::stoul(s, nullptr, 16);Documentation