On Sat, Jun 21, 2003 at 10:14:12AM +0000, [EMAIL PROTECTED] 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.

        Cheers,

        Matthew


-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to