c - 安思 C : Long Double Variable Printing Out to a Value of 0. 000000

标签 c ansi

这个问题在这里已经有了答案:





gcc: printf and long double leads to wrong output. [C - Type conversion messes up]

(5 个回答)


6年前关闭。




当我运行下面的 Ansi C 程序时,会打印出“0.000000”的值。有谁知道为什么值“561.308000”没有被打印出来?我使用的是 Dev-C++ 来运行程序,我使用的编译器是:GCC 的 Mingw 端口(GNU Compiler Collection),版本 MSVCRT 2.95.2-1。

#include <stdio.h>
#include <stdlib.h>

main()
{
    long double x = 561.308;
    printf("%Lf",x);
}

最佳答案

编译 gcc (GCC) 4.8.1在使用此命令的 Windows 7 64 位上工作。 (将 -std=c99 添加到让编译器与 C99 一起工作的选项中)
gcc -Wall -Wextra -std=c99 test.c -o test.exe

关于c - 安思 C : Long Double Variable Printing Out to a Value of 0. 000000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32686906/

相关文章:

C 计数器意外重置

c - 在 RHEL 服务器中编译 C 文件时出错

c - 在 eclipse (Fedora) 上的 c 程序中未定义对 pthread_create 的引用

c - C中的数据类型(字符)

c - 什么样的非致命代码通常会触发防病毒软件? (误报)

c - 为什么 GCC 对 void-pointer 算术的接受不被认为是一个错误?

inno-setup - 在 Inno Setup 中使用 {AppVersion} 作为函数的参数

c - NetBSD:编译 cwm 后动态库错误

c++ - 在 OSX 上链接 OpenGL 框架

unicode - 通过 FTP 将 ANSI 字符串写入 Unicode 文件