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

Re: printf and cout

Subject: Re: printf and cout
From: Bernhard Schauer
Date: Wed, 26 Mar 2008 10:01:13 +0100
Newsgroups: comp.lang.c

> int c = 400;
> printf("%c", c);
> 
> it print ? on screen, and ascii of '?' is 63.
> 
> but
> cout << int(char(400));
> 
> it print -112 on screen.
> 
> so, my question is why comes 63 and -112, what relations between them,
> why printf and cout behavior so differently.

Hi!

both values are the same, except that the '?' is not meant as the
character '?' but as an unprintable character. It also "looks" different
than a normal '?'.

regards

-- 
Bernhard Schauer
schauer_at_cruxy_dot_net

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