Andrew said:
.... snip ...
int main(void)
{
/* puzzle. Why will this code break if we make a x a size_t ? */
unsigned long x = 0;
while(malloc(1))
x++;
printf("You have %lu bytes available\n", x);
return 0;
}
Because printf can't handle a size_t?
Exactly. You should cast x to (unsigned long). This will work on
C90 systems, provided only that an unsigned long can express a
size_t. For C99 you can use %z (I think).
--
"Our enemies are innovative and resourceful, and so are we.
They never stop thinking about new ways to harm our country
and our people, and neither do we." -- G. W. Bush.
"The people can always be brought to the bidding of the
leaders. All you have to do is tell them they are being
attacked and denounce the pacifists for lack of patriotism
and exposing the country to danger. It works the same way
in any country." --Hermann Goering.