You’re using the wrong conversion specifier in both scanf
and printf
. To read a double
value with scanf
you need to use %lf
and to print a double
value with printf
you need to use %f
.
Because of how those functions work, they don’t know the number, type, or order of arguments you’ve actually passed to them - they just see a sludge of bytes on the stack or a sea of argument registers. The only way for them to know what arguments they should expect is through what you specify in the format string.
%d
is used to read and print int
types, %c
for individual characters, %s
for strings, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…