C中的长双数据类型问题

avd*_*avd 2 c

在下面的代码中,printf打印-0.00000.问题是什么?如果它是双倍而不是长双倍,那么它工作正常.

#include<stdio.h>
long double abs1(long double x) {
    if (x<0.0)
        return -1.0*x;
    else
        return x;
}

main() {
    long double z=abs1(4.1);
    printf("%llf\n",z);
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*off 9

长双的正确打印格式%Lf.打开编译器的警告会立即指出错误:

$ gcc -Wall b.c -o b
b.c:9: warning: return type defaults to `int'
b.c: In function `main':
b.c:11: warning: use of `ll' length modifier with `f' type character
b.c:11: warning: use of `ll' length modifier with `f' type character
b.c:12: warning: control reaches end of non-void function