This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unable to output unsigned char/char in hex


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@gmail.com>
To: Arthur Schwarz <aschwarz1309@att.net>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]