What will be the behavior and output of the following c开发者_运维技巧ode if i accidentally code so in C/C++,
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
Rubish and more rubish.
You would get something meaningful if you did the following though
printf("%d\n", (int)a);
its undefined, because ANSI defines not a relation between sizeof(int) and sizeof(float).
精彩评论