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

Re: printf and cout

Subject: Re: printf and cout
From: Richard Heathfield
Date: Fri, 28 Mar 2008 18:51:52 +0000
Newsgroups: comp.lang.c

Ben Bacarisse said:

> Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:
> 
>> jacob navia said:
>>
<snip>
>>> 
>>> That's what I am talking about. Obviously your example
>>> will work.
>>> 
>>> printf("%c",12345678);
>>> 
>>> will not!
>>  
>> It is certainly true that it is not guaranteed to work. It is not
>> guaranteed *not* to work, however. On systems with CHAR_BIT >= 24, it
>> /will/ work (although heaven knows what character will be
>> printed!).
> 
> Now I am confused!  How could it "not work" on any system?

if 12345678 is not representable as an int, it will fail right there. As it 
turns out, though, I was being overly conservative in an attempt not to 
disagree too much with Mr Navia. I was assuming (wrongly) that the int 
value had to be representable as an unsigned char. It doesn't.

<snip>

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