is this a FBSD printf bug?
m.seaman at infracaninophile.co.uk
Sat Jun 21 03:45:01 PDT 2003
On Sat, Jun 21, 2003 at 10:14:12AM +0000, abc at ai1.anchorage.mtaonline.net wrote:
> i hope this isn't a question based on extreme
> ignorance - i haven't programmed in C in a
> long time, and i don't have another machine
> to test this on. i can't understand why
> the output of the following code produces
> "ints" when given variables of type "char",
> so it looks like a bug to me ...
Nope -- this is a C language FAQ (See
http://www.faqs.org/faqs/C-faq/faq/, particularly section 15).
Neither is it FreeBSD specific. If you pass arguments to a varargs
function, like printf(3), then they will get type promoted. In this
case 'char' is promoted to 'int'. The reason the results you're
seeing don't match up to your expectations is that the 'char' type is
signed, and you seem to want to be using an unsigned type.
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030621/b613265d/attachment.bin
More information about the freebsd-questions