Code :: Blocks无法在简单的C程序中识别双标识符(%lf)

问题描述 投票:2回答:2

[今天,我决定回顾一下C编程语言的基础知识,并且在Code :: Blocks IDE中遇到了这个小问题:当我使用%f格式标识符读写十进制数时,一切顺利,但是当我切换到%lf格式标识符时,它无法正确读取或写入数字。

这是我的代码:

#include <stdio.h>

int main()
{
    double x;
    scanf("%lf", &x);
    printf("x = %lf", x);
    return 0;
}

enter image description here

这是输出:enter image description here

这些是Code :: Blocks菜单中的编译器设置:enter image description here

我已经在线搜索了一个解决方案,包括Code :: Blocks论坛,但是我没有发现任何相关的解决方案。我不确定是编译器问题还是IDE问题。如果您知道修复程序或对此问题有解释,请帮助我。我敢肯定其他人也会遇到此问题。

c printf double scanf codeblocks
2个回答
1
投票

尚不清楚是什么Code :: Blocks警告。 lf格式字符串中的scanf也带有下划线,但绝对正确,因为目标变量的类型为double


0
投票

对该线程有兴趣的人对此问题进行了更详细的描述:Correct format specifier for double in printf

© www.soinside.com 2019 - 2024. All rights reserved.