>c assigns a negative ASCII value to some symbols
No, C assigns a negative integral value to the variable and the system happens to have a printable representation for that value. It doesn't mean that it's ASCII.
>I expect that in your system char == unsigned char.
No, if that were the case the the loop would terminate after ch reached 0. This is because the value would roll around to the largest unsigned value for char. That value is larger than the ASCII value for 'Z', so the loop would break successfully. The fact that the OP is seeing negative values is an indicator that the default type for char is signed, not unsigned.
>If you know about it, it can be very useful.
Very useful for breaking things.
>for ( signed char x=1; x != 0; ++x )
This is undefined behavior. You're overflowing a signed integral type.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
there are a lot of unprintable characters between 0 and 255. Look at any ascii chart such as this one and you see that printable chars start with decimal value 32 (a space) and ends in decimal value 126 the tilda ~. Values above and below those two values may or may not be pritable, depending on the code, or language, set.
So if you try to print one of those non-printable characters to a file in its binary form (which is probably what happened in the text file you posted) all you will most likely see in the file is a funny-looking square when displayed with Notepad. Other text editors may display them as some other symbol or not at all.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343