|
|
On Mar 26, 1:51 am, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
> laikon said:
>
> > Hello, everyone:
>
> > this is about overflow in C and C++.
>
> The behaviour of a C program on overflow is undefined.
>
> > int c = 400;
> > printf("%c", c);
>
> > it print ? on screen,
>
> Not necessarily. C doesn't guarantee you a screen, and it says very little
> about the character set supplied by your implementation.
>
> > and ascii of '?' is 63.
>
> This is irrelevant, I think. If by some chance you'd seen the character
> with code point 144 (which is, of course, *not* an ASCII character), I'd
> have been able to explain it in concrete terms. I am a little puzzled by
> the 63, actually. Try dumping the character to a file and examining a hex
> dump thereof.
>
> > but
> > cout << int(char(400));
>
> > it print -112 on screen.
>
> You might want to ask that in comp.lang.c++
>
> --
> 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
thanks very much.
I just know:
the printed '?' does not mean to be the result of the overflow, but a
symbol of unknown ascii character. when a number overflows by char,
and the left binary is negate, the printf will print '?'.
|
|