Matthew Saltzman wrote:
It will definitely print *something*. The question is, can you
guarantee what it will print.
In C89, no in C99, yes.
It's not addressed directly in the FAQ, but I believe it's possible to
prove that (unsigned) -2 must be the two's complement representation of
-2 in however many bits make up an int. I know there was some
controversy about that when the standard was being developed. In any
case, I don't know of any modern machine that doesn't represent negative
integers in two's complement.
Reach into your pocket, and pull out your calculator.
[snip]
sizeof(char) == 1 is guaranteed by the standard. There's no reference
to "bytes", but it is commonly accepted that the char type is a byte.
Erm, from the Standard:
3.4
[#1] byte
addressable unit of data storage large enough to hold any
member of the basic character set of the execution
environment
It's possible to have chars that are not eight bits, but I can't think
of a modern machine that does that. There were some old machines
(Honeywells?) that had six-bit bytes and 36-bit words.
All this is based on my recollection of discussions in comp.lang.c and
comp.std.c when the standard was under development.
Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!