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