更新时间:2022-04-11 05:59:02
对于scanf()
,%f
用于float
.您需要将%lf
用于double
:
For scanf()
, %f
is for float
. You need to use %lf
for double
:
printf("Enter a # for square root.\n");
scanf("%lf",&a);
这与printf()
相反,在printf()
中,类型促销允许%f
用于float
和double
.
This is in contrast to printf()
where type-promotion allows %f
to be used for both float
and double
.