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

Re: printf and cout

Subject: Re: printf and cout
From: Keith Thompson
Date: Fri, 28 Mar 2008 11:33:39 -0700
Newsgroups: comp.lang.c

jacob navia <jacob@xxxxxxxxxx> writes:
[...]
> Well OK
>
> "%c" format specifier expects an int.

Correct.

> GREAT!
>
> I am tired of this discussion.

Funny that you happen to get "tired" of it just at the moment when you
realize you made a mistake.

>                                You are right, I was wrong

Yes, I was right.  Yes, you were wrong.  But it's not such a
huge deal.  We all make mistakes.  I make mistakes all the time,
and I'm grateful when people point them out.  And I usually accept
corrections without sarcasm.

> and when everybody uses "%c" to put a character they are
> totally wrong.

And now you're being ridiculous.  This:

    char c = 'x';
    printf("%c", c);

is perfectly valid, because the char value is promoted to int,
which is what printf expects for "%c".  (Except in the obscure
case that plain char is unsigned and sizeof(int) == 1, but I'm
willing to ignore that (other than this brief mention for the sake
of completeness).)  But of course you know that.

Pointing out an error is not a personal attack.  Learn that and
you might be taken a lot more seriously around here.

-- 
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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