[HH] c++ strings?

Greg London email at greglondon.com
Thu Dec 13 18:33:30 EST 2012


Hmm. C++ is NOT helping here.

   char mybyte=0x52;
   int myint=0x52;

   cout<<"byte->"<<std::hex<<mybyte<<"<-byte"
       <<"int->"<<std::hex<<myint<<"<-int"<<endl;

   output is:: byte->R<-byte  int->52<-int


It wants to print any 8 bit type, signed or unsigned, as a character,
even if there's a std::hex in front of it.

Is there an easy fix for this?

I could fake it out by converting the byte to an int,
and then masking the upper bits I suppose.

But it makes dealing with 8 bit data a bit of a pain.

Greg



> That's it.
> Thanks!
>
>
>> Try this:
>> ss << "actual=0x" << std::hex << actual << " expected=0x" << std::hex <<
>> expected << " " << msg;
>>
>> --
>> Jerry Feldman <gaf at blu.org>
>> Boston Linux and Unix
>> PGP key id:3BC1EB90
>> PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90
>>
>>
>> _______________________________________________
>> Hardwarehacking mailing list
>> Hardwarehacking at blu.org
>> http://lists.blu.org/mailman/listinfo/hardwarehacking
>>
>
>
> --
>
>
> _______________________________________________
> Hardwarehacking mailing list
> Hardwarehacking at blu.org
> http://lists.blu.org/mailman/listinfo/hardwarehacking
>


-- 





More information about the Hardwarehacking mailing list