if its for display later, maybe a stringstream and treat it just like cout, then when you need it, its there.
that will do the same auto conversion/formatting that cout would do with the same output manipulations.
The WinAPI virtual key codes are #defines, they are representations of hex numbers.
You make it sound like "hex numbers" are some special type of number. Hex(adecimal) is just an alternative way to write numbers. 0x11 and 17 represent the same value in C++. Once you store them in a variable you won't be able to tell them apart.
George P wrote:
Converting a number, even a hex number, to a string is doable.
"hex" is rather a property of the string (the textual representation of the number) than the number itself. A number is just a number, it doesn't contain information about how it should be displayed. It's when you print it or convert it to string that you got to choose if you want to use the default decimal notation (base 10), hexadecimal (base 16), binary (base 2) or the more uncommon octal (base 8). Other notations (e.g. quinary, base 5) are of course also possible but then you can not expect much help from the standard library.