Possible Duplicate:
how do I print an unsigned char as hex in c++ using ostream?
Convert ASCII string into Decimal and Hexadecimal Representations
I want to print out the hex value of characters using isprint(). However, I cannot get it to work. This is my attempt:
getline(cin, w);
for(unsigned int c = 0; c < w.size(); c++)
{
if(!isprint(w[c]))
{
cout << "ERROR: expected <value> found " << hex << w[c] << endl;
return 0;
}
}
Can anyone help me print out this hex value? Thanks! I'm inputting things like:
í
and I want it's hex value.