Using printf function

后端 未结 5 828
时光说笑
时光说笑 2021-01-22 13:01

I\'ve never bothered to look for printf as I started learning C++ without C. Now i want to use formatted output in some project. so I\'m looking for some references that can exp

5条回答
  •  离开以前
    2021-01-22 13:07

    It actually invokes undefined behavior (UB). If the format specifier doesn't match with the type of the argument passed to printf, then it is UB, which means anything could happen. It can print 0, or 9878978 or any garbage. Anything, entirely unpredictable, could happen.

    Use %f if the data type of the argument is float.

提交回复
热议问题