Printf "%#6.4o\n"

printf e$B$Ge(B %#6.4o e$B$K$h$je(B 1, 0, -1
e$B$r%U%)!<%^%C%H$7$?7k2L$O0Je(B
e$B2<$N$h$&$K$J$j$^$9!#e(B

% ./ruby -ve ‘1.downto(-1) {|n| printf “%#6.4o\n”, n }’
ruby 1.9.0 (2008-01-26 revision 15257) [i686-linux]
00001
0000
…77

C e$B$G$O!"e(B(C e$B$Ne(B %o e$B$OId9f$J$7$J$N$Ge(B 1, 0 e$B$K$D$$$Fe(B)
e$B0J2<$N$h$&e(B
e$B$K$J$j$^$9!#e(B

% cat tst.c
#include <stdio.h>

int main(int argc, char **argv)
{
printf("%#6.4o\n", 1);
printf("%#6.4o\n", 0);
return 0;
}

% gcc -Wall tst.c
% ./a.out
0001
0000

width e$B$,e(B 6 e$B$J$N$Ge(B 6e$B7e$K$J$ke(B C
e$B$N7k2L$,E,@Z$@$H;W$$$^$9!#e(B
e$B$=$l$H$N0l4S@-$+$i$7$F!“e(B-1 e$B$N$H$-$Ne(B " …77” e$B$be(B
6e$B7e$K$J$k$h$&e(B
e$B6uGr$,$b$&$R$H$DI,MW$@$H;W$$$^$9!#e(B

e$B$^$?!“e(B1 e$B$r%U%)!<%^%C%H$7$?7k2L$,e(B " 0001”
e$B$K$J$k$N$O!"e(B8e$B?J$NBee(B
e$BBX7A<0$Oe(B precision e$B$rA}$d$9$h$&$JF0:n$G!“e(B1 e$B$N>l9ge(B
4e$B7e$G$9$Ge(B
e$B$K@hF,$,e(B 0 e$B$J$N$Ge(B precision
e$B$rA}$d$5$J$$$?$a$@$H;W$$$^$9!#5,e(B
e$B3Je(B (ANSI C) e$B$K$O0J2<$N$h$&$K=q$$$F$”$j$^$9!#e(B

   #     The result is converted to  an  ``alternative  form''.
         For  o  conversion, it increases the precision, if and
         only if necessary, to force the  first  digit  of  the
         result  to  be  a zero (if the value and precision are
         both 0,  a  single  0  is  printed).