On Sun, 17 Oct 2004 22:40:03 -0500, Artie Gold
<ar*******@austin.rr.com> wrote:
Magix wrote: Hi,
unsigned long hex1;
hex1=0x12345678;
printf("Hex1: %#X",hex1);
Why it only print 0x5678, instead of 0x12345678?
Turn up the warning level on your compiler. the `X' format specifier is
for printing `int's. The variable `hex1' is a long. Use `lX'.
To be precise, X is for unsigned int, which is apparently 16-bit on
the OP's implementation, and lX unsigned long, which is correct.
Turning up warnings only helps on one compiler I know of, although a
very widespread one. This is not a required diagnostic in the
standard, and not commonly implemented, although rather nice.
(Posting to c.l.c however will get you all kinds of diagnostics no
compiler provides, or likely ever will or can. <G>)
- David.Thompson1 at worldnet.att.net