scanf - limit decimal places while reading
我知道如何在printf(%xx)中打印值时限制十进制和整数,在我的场景中,我想在从控制台读取它的lef时实现它。
所以有什么方法可以限制
我在下面尝试过,在编译时不显示任何错误,但始终为0,总是浮点值的小数位数。
如果您查看文档,它会显示
scanf:
A format specifier for scanf follows this prototype:
%[*][width][length]specifier
并将其与printf:
A format specifier follows this prototype:
%[flags][width][.precision][length]specifier
进行比较,您会发现,没有scanf中的