Why does printf print wrong values?

后端 未结 7 1479
情歌与酒
情歌与酒 2020-12-01 22:19

Why do I get the wrong values when I print an int using printf(\"%f\\n\", myNumber)?

I don\'t understand why it prints fine with %d

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 23:06

    For "normal" (non variadac functions with all the types specified) the compiler converts integer valued types to floating point types where needed.

    That does not happen with variadac arguments, which are always passed "as is".

提交回复
热议问题