c语言中%f输出double型和float型值
001、
[root@PC1 test]# ls test.c [root@PC1 test]# cat test.c #include <stdio.h> int main(void) { double i; //声明double型 和 float型变量 float j; i = 3.14; j = 3.14; printf("i = %f\n", i); printf("j = %f\n", j); return 0; } [root@PC1 test]# gcc test.c -o kkk // 编译 [root@PC1 test]# ls kkk test.c [root@PC1 test]# ./kkk ## 结果表明%f可以输出double和float型;(前期测试%lf也可以输出double和float型); 区别在哪里? i = 3.140000 j = 3.140000
。