Getting a buffer into a stringstream in hex representation:
问题 If I had a buffer like: uint8_t buffer[32]; and it was filled up completely with values, how could I get it into a stringstream, in hexadecimal representation, with 0-padding on small values? I tried: std::stringstream ss; for (int i = 0; i < 32; ++i) { ss << std::hex << buffer[i]; } but when I take the string out of the stringstream, I have an issue: bytes with values < 16 only take one character to represent, and I'd like them to be 0 padded. For example if bytes 1 and 2 in the array were