Type conversion, why the output is 0?

-sharpinclude <stdio.h>
int main()
{
    int i = 15;
    float m = (float)i;
    printf("%d\n", m);
    return 0;
}
Why is the result of

output 0?
I know that floating-point output should be% f instead of% d, but why? Why is the% d output floating point result 0?

C
Feb.27,2021

is clearly float, but output with d , which is undefined behavior . The so-called undefined behavior means that the compiler can do anything, such as outputting 0, or 15, or junk numbers for you, or simply crashing the program.

clipboard.png


7.5f,111.11.1112^2,S022+127 = 129;10000001;111;7.50100 0000 1111 0000 0000 0000 0000 0000;floatdouble8S01100010000001;111:0000 1000 0001 1110 0000 0000 0000 0000:0000 0000 0000 0000 1110 0001 1000 0000
%d 40;


: float m %d


should be the problem of% d changed to% f or% lf

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37215-2c053.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37215-2c053.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?