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

Re: printf and cout

Subject: Re: printf and cout
From: Richard Heathfield
Date: Wed, 26 Mar 2008 10:46:08 +0000
Newsgroups: comp.lang.c

Bernhard Schauer said:

> santosh wrote:
> 
> <snip>
>> Actually they don't behave differently at all. In each case the int
>> value 400 is being interpreted as an unsigned char.
> <snip>
> 
> Code from laikon:
>> int c = 400;
>> printf("%c", c);
>> cout << int(char(400));
> 
> Where exactly do you see unsigned characters? (char != unsigned char)

When printf is handed a %c, it converts the corresponding int argument to 
an unsigned char. See 4.9.6.1 of C89 or 7.19.6.1(8) of C99.

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -                                www">http://www. +rjh@
Google users: <                                www.cpax.org.uk/prg/writings/googly.php">http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

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