在我这边 long double 没问题,但是 double 什么都不显示$ cat main.c
#include<stdio.h>
int main()
{
int r;
long double c,s;
r=5;
c=2*3.14*r;
s=3.14*r*r;
printf("c=%6.2Lf,s=%6.2Lf",c,s);
return 0;
}
$ gcc -g -Wall -o main main.c
$ ./main
c= 31.40,s= 78.50$ vim main.c
$ cat main.c
#include<stdio.h>
int main()
{
int r;
double c,s;
r=5;
c=2*3.14*r;
s=3.14*r*r;
printf("c=%6.2Lf,s=%6.2Lf",c,s);
return 0;
}
$ gcc -g -Wall -o main main.c
main.c: In function ‘main’:
main.c:10:20: warning: format ‘%Lf’ expects argument of type ‘long double’, but argument 2 has type ‘double’ [-Wformat=]
10 | printf("c=%6.2Lf,s=%6.2Lf",c,s);
| ~~~~~^ ~
| | |
| long double double
| %6.2f
main.c:10:29: warning: format ‘%Lf’ expects argument of type ‘long double’, but argument 3 has type ‘double’ [-Wformat=]
10 | printf("c=%6.2Lf,s=%6.2Lf",c,s);
| ~~~~~^ ~
| | |
| | double
| long double
| %6.2f
$ ./main
$
|