Printf "%-05d\n", 1

e$B0J2<$N$h$&$Ke(B printf e$B$Ge(B %-05d e$B$Ke(B 1 e$B$rM?$($?7k2L$Oe(B
00001 e$B$K$Je(B
e$B$j$^$9!#e(B

% ./ruby -ve ‘printf “[%-05d]\n”, 1’
ruby 1.9.0 (2008-01-26 revision 15257) [i686-linux]
[00001]

e$B$7$+$7!"e(BC e$B$N5,3J$G$O%U%i%0$H$7$Fe(B - e$B$He(B 0
e$B$NN>J}$rM?$($?>l9g!“e(B
0 e$B$rL5;k$9$k$3$H$K$J$C$F$*$j!”$3$l$H$O0[$J$k7k2L$K$J$j$^$9!#e(B

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

int main(int argc, char **argv)
{
printf("[%-05d]\n", 1);
return 0;
}
% gcc -Wall t.c
t.c: In function ‘main’:
t.c:5: warning: ‘0’ flag ignored with ‘-’ flag in printf
format
% ./a.out
[1 ]

gcc e$B$,$=$&$$$&7Y9p$r=P$7$F$$$k$N$O5,3J$,$=$&$J$C$F$$$k$+$i$Ge(B
e$B$9$,!"$=$N5,3J$I$*$je(B 0 e$B$OL5;k$5$l!"e(B-
e$B$K$h$k:85M$a$K$J$C$F$$e(B
e$B$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs