671 :
647:
// %fより%gを使えと言う主張のもと、%gの普及に努めるサンプル(ぉぃ
#include <stdio.h>
void printInt(int foo)
{
printf("%d %0d\t指定なし(%%d, %%0d)\n"
"%.4d %0.4d\t精度指定(%%.4d, %%0.4d)\n"
"1-------9 1-------9\n"
"%9d %09d\t幅指定(%%9d, %%09d)\n"
"%9.4d %09.4d\t幅と精度指定(%%9.4d, %%09.4d)\n\n",
foo, foo, foo, foo, foo, foo, foo, foo);
}
void printDouble(double foo)
{
printf("%e %f %g\t指定なし(%%e, %%f, %%g)\n"
"%.4e %.4f %.4g\t精度指定(%%.4e, %%.4f, %%.4g)\n"
"1---------12 1---------12 1---------12\n"
"%12e %12f %12g\t幅指定(%%12e, %%12f, %%12g)\n"
"%12.4e %12.4f %12.4g\t幅と精度指定(%%12.4e, %%12.4f, %%12.4g)\n\n",
foo, foo, foo, foo, foo, foo, foo, foo, foo, foo, foo, foo);
}
int main()
{
printInt(123);
printDouble(12345.67);
printDouble(1.234567);
printDouble(0.00001234567);
return 0;
}