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

Re: printf and cout

Subject: Re: printf and cout
From: Keith Thompson
Date: Fri, 28 Mar 2008 08:29:52 -0700
Newsgroups: comp.lang.c

jacob navia <jacob@xxxxxxxxxx> writes:
> pete wrote:
>> santosh 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

Are you saying there's something wrong, or even unexpected, with this?

#include <stdio.h>
int main(void)
{
    int c = '\n';
    printf("%c", c);
    return 0;
}

The expected argument normally has a value that's representable as an
unsigned char, but its expected type is int.

-- 
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