On Sat, 13 Jan 2007 22:16:45 +0000, Angus wrote:
> But I have some ascii values as hex - eg 0xa1. I can't do this:
>
> oss << 0xa1;
>
> Well, I can but I just get the decimal number of the value added. I just
> want to append the ascii value to the string - it is a funny i sort of
> character in this example.
By itself, 0xa1 is of type "int", so the compiler selects the "int"
version of the insertion operator. If you want it to be a char, you
must use a cast, store the value in a variable of type char, or use an
escaped character literal. For example,
oss << static_cast<char>(0xa1);
or
char var = 0xa1;
oss << var;
or
oss << '\xa1';
Gregg
|