Why does printf print wrong values?

后端 未结 7 1475
情歌与酒
情歌与酒 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条回答
  •  半阙折子戏
    2020-12-01 22:55

    a, b, c, d and e aren't floats. printf() is interpreting them as floats, and this would print weird stuff to your screen.

提交回复
热议问题