C语言基础:格式化浮点数输出
#include <stdio.h> int main () { float value = 1.23456; printf ("%8.1f\n", value); printf ("%8.3f\n", value); printf ("%8.5f\n", value); return 1; }
gcc编译输出结果
1.2 1.235 1.23456
C语言基础:格式化浮点数输出
#include <stdio.h> int main () { float value = 1.23456; printf ("%8.1f\n", value); printf ("%8.3f\n", value); printf ("%8.5f\n", value); return 1; }
gcc编译输出结果
1.2 1.235 1.23456