is this a FBSD printf bug?

Matthew Seaman m.seaman at
Sat Jun 21 03:45:01 PDT 2003

On Sat, Jun 21, 2003 at 10:14:12AM +0000, abc at 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, 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
                                                      Savill Way
PGP:         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list