A: |
You probably tried something like
printf ("%d", sizeof (something));
The ANSI standard proposes that the sizeof operator returns
a value of type size_t, which is in fact long integer in
this implementation. So, the result is pushed on the stack as a long integer, but the format
specifier "%d" expects an ordinary integer, so it pulls from the stack just one word, which
is zero in this case. You need to write
printf ("%ld", sizeof (something));
Alternatively, you can use a typecast to convert the result to a short integer
printf ("%d", (short) sizeof (something));
assuming that no object would be longer that 32767 bytes.
|