Re: Unable to output unsigned char/char in hex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks. Is there any way to output a unsigned char/char value without casting it 
to (int) (long ...)?

One reason to do this is to preserve the size of the char. A byte is not defined 
as 8-bits. 8-bits is defined as an octet. I have seen byte sizes of 6, 7, 8, 9, 
12, and 16 bits on various pieces of hardware and whether a wide-char is used. 
Forcing the char to int changes the number of bits used. There are other ways of 
treating the problem(s) but I wonder if there is a way to just output a char in 
hex directly.

art



----- Original Message ----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
To: Arthur Schwarz <aschwarz1309@xxxxxxx>
Cc: "gcc-help@xxxxxxxxxxx" <gcc-help@xxxxxxxxxxx>
Sent: Thu, August 9, 2012 2:46:34 PM
Subject: Re: Unable to output unsigned char/char in hex

On 9 August 2012 22:10, Arthur Schwarz wrote:
> The code (below) is an output example. Hex output occurs for all the numeric
> types but not for unsigned char/char. Does hex only work for numeric values, 
>and
> how do I force hex output? cout.setf(ios::hex) does not work.

http://stackoverflow.com/a/3756406/981959



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux