I'm trying to get the hex values from file data that I imported into a character buffer. I use a stringstream to convert each char to a hex string but it is not in the format that I want.
My question is how to convert "ffffffae" to "ae" and "0" to "00". I guess I could just go through each string individually and add/remove the characters, but isn't there a better way?
----- EDIT -----
Got it! Thanks to GeneralZod at the Ubuntu forums:
1 2 3 4 5 6 7 8 9 10 11
#include <iomanip>
.....
for (int x = 0; x < length; x++)
{
stringstream ss;
ss << "0x" << hex << setw(2) << setfill('0') << (int)(unsignedchar)data1[x];
data2[x] += ss.str();
cout << data2[x] << endl;
}
.....