c.***********@gmail.com said
consider following code snippet..I will be making assumptions here about your system that will
________________________
float a=3.0;
int b=1,c=2;
printf("%d %d %d ",a,b,c);
_________________________
above code give output
0 0 0
i can understand first zero as wrong format(%d) given for a,but i
could not get that why b and c are also printing as zero....
infuriate the pedants, but I don't care. Given your X-HTTP-UserAgent
string, it is highly probable that these assumptions are valid.
Whether you have included stdio.h or not, the float argument to
printf() is promoted to a double, since even with a prototype
visible, the float falls into the variable-list part of the
variadic function printf().
On your system, a double has a 64-bit double-precision IEEE-754
floating-point representation, which means the float 3.0 will be
promoted and represented as 0x4008000000000000.
On your little-endian system, the 0x00 bytes will occur first
in memory.
On your system with 16-bit ints, the %d format specifiers will
operate on 0x0000, 0x0000, 0x0000.
To confirm my explanation, change
printf("%d %d %d ",a,b,c);
to
printf("%d %d %d %d",a,b,c);
and your output should be
0 0 0 16392
Yours,
Han from China