comp.lang.c
[Top] [All Lists]

Re: printf and cout

Subject: Re: printf and cout
From: pete
Date: Fri, 28 Mar 2008 07:46:39 -0500
Newsgroups: comp.lang.c

Richard Tobin wrote:
> 
> In article <fsinv9$v6h$1@xxxxxxxx>,
> jacob navia  <jacob@xxxxxxxxxx> wrote:
> 
> >>> The %c format expects
> >>> (and thus treats the corresponding argument as) an unsigned char.
> 
> >> No standard library functions are described
> >> as taking an argument lower ranking than int.
> 
> >Yes, but the character is promoted to int only for passing it
> >to printf. The expected argument is a char, not an int
> 
> It's often true that the argument is a char which gets promoted to
> int, but that's not required - the standard says int, not char - and
> it's often not a char.  It's perfectly normal to store characters in
> an int (consider the value returned by getchar() for example), and
> of course character constants are ints not chars.
> 
> On the other hand, I think it's true that the only reason it's an
> int is because of the deafult promotions.  If it weren't for that,
> it would make more sense for it to be an unsigned char.

That's what I think too.

-- 
pete

<Prev in Thread] Current Thread [Next in Thread>