|
|
Keith Thompson wrote:
>
> 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.
This will output the same thing
even though the int argument is negative:
printf("%c", 'x' - 1 - (unsigned char)-1);
except in that obscure case that you mentioned.
--
pete
|
|