且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 scanf 在提供双精度值时返回 0.000000?

更新时间:2023-11-12 14:37:52

您正在尝试使用 '%f' 标记扫描浮点数,但提供了一个双精度数.将浮点变量传递给 scanf,然后转换为双精度变量或将 '%lf' 作为格式字符串传递给 scanf.

You are trying to scan a float with the '%f' token but providing a double. Pass in a float variable to scanf and then convert to a double or pass in '%lf' as the format string to scanf.